Hi =?Utf-8?B?Y2FzaGRlc2ttYWM=?=,
In the code, I read from the XML file with:
Dataset1.ReadXML("..\\..\\Student.xml");
This ran fine during debugging as the ..\\..\\ simply bumps it up a
couple of folders to the bin folder, where it can be read. However,
once deployed it bumped the search up to my C:\ drive. I tried to
create a sub-folder under the application folder in my set up but it
still couldn't find the file.
You are reading from an relative path!
If the file is shipped with your app you should consider using the Path
of your exe as start-path...
// Assuming Student.xml is on the same dir as the exe:
Dataset1.ReadXML(System.IO.Path.Combine(App.Startu pPath, "Student.xml"));
See: How to get the .NET applications path?
http://blog.kalmbachnet.de/?postid=7
<code>
<public class App
{
[System.Runtime.InteropServices.DllImport("kernel32 .dll",
SetLastError=true)]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern uint GetModuleFileName(
[System.Runtime.InteropServices.In]
IntPtr hModule,
[System.Runtime.InteropServices.Out]
System.Text.StringBuilder lpFilename,
[System.Runtime.InteropServices.In]
[System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.U4)]
int nSize
);
public static string StartupPath
{
get
{
System.Text.StringBuilder sb = new System.Text.StringBuilder
(260);
if (GetModuleFileName(System.IntPtr.Zero, sb, sb.Capacity) == 0)
throw new System.ApplicationException("Could not retrive module
file name");
return System.IO.Path.GetDirectoryName(sb.ToString());
}
}
}
</code>
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/