Click here to Skip to main content
15,881,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i created a windows form application in vs 2012 ,when published this and install and run i get this erro :(

Could not find a part of the path 'C:\Users\SadeQ\AppData\Local\Apps\2.0\5ELTCO6N.RGC\Data'
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\SadeQ\AppData\Local\Apps\2.0\5ELTCO6N.RGC\Data'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.DirectoryInfo.InternalGetDirectories(String searchPattern, SearchOption searchOption)
at System.IO.DirectoryInfo.GetDirectories()
at Autorun.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Autorun
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/SadeQ/AppData/Local/Apps/2.0/5ELTCO6N.RGC/2QVLQ2M4.3VG/auto..tion_e40b3abd960f3d93_0001.0000_269312d74a6f2509/Autorun.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitdebugging="true">


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

(SadeQ is my user)

i created a folder "Data" and put this in /bin/Debug/Data
my c# code for access folder "Data"


C#
private void Form1_Load(object sender, EventArgs e)
{
    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(System.AppDomain.CurrentDomain.BaseDirectory + @"\Data");
    foreach (var folder in dir.GetDirectories())
    {
        listBox1.Items.Add(folder.Name);
    }
    listBox1.SelectedIndex = 0;
}
Posted

Probably, it is a permissions and / or folder creation problem: you really shouldn't be trying to store any data (or anything else you change) under your application folder, as access to "Program Files" and related folders is tighter than it was, and likely to get tighter - the idea is to prevent accidental of deliberate changes to programs and their components, and also to ensure tit is easier to backup data files.

Instead, look at using the Windows special locations to store data - it's easy, future proff and safer. This can help: Where should I store my data?[^]
 
Share this answer
 
There is problem with the path you provide. Please re cehck with the path of the data folder. Its unable to find the specified path in you loacl system. Plz let me know it it still not working.
 
Share this answer
 
Comments
SadeqHatami 11-Sep-13 2:55am    
i get data folder path from this code:
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(System.AppDomain.CurrentDomain.BaseDirectory + @"\Data");

whene i run the application in VS2012 it's work fine , but after publish and install i get same erro :(
[no name] 11-Sep-13 3:05am    
After publish are you trying to run the code fro the same system?
because may be after publishing system unable to map your path which it earlier can able to find.
SadeqHatami 11-Sep-13 3:52am    
yes, i test it in same system and other system , and get error
Now what should I do?
[no name] 11-Sep-13 4:31am    
better instead of this way you save the path in web config file and from there you can read that folder path. just try in that way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900