Log in

View Full Version : Help - 'System.IO.FileNotFoundException' though the file is available


raghuraman_ace
06-28-2005, 07:24 PM
Hi,

am using .net smart device application using c#.net.
i am trying to load the dataset from reading the xml file named pdatext.xml which is available at inside the 'debug' folder of the project.

But if i read the xml file using

dataset ds=new dataset("dss");
ds.Readxml("pdatext.xml");

IT TELLS THE FOLLOWING ERROR.

---------------
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Xml.dll
Additional information: FileNotFoundException
----------------

** But the same is working well for the normal windows application.

Pls tell me how can i solve this

JonMisurda
06-29-2005, 06:01 AM
relative paths are not supported on the pocketpc, so my guess is that its looking for \pdatext.xml (in the root directory) and not finding it.

If you want the file to be located in the same directory as the program, you could do this to get that directory:


string path = Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
);

and then concatenate:

ds.Readxml(path + "\\pdatext.xml");

Hope that helps,

Jon

raghuraman_ace
06-29-2005, 10:20 AM
Dear Jon

Great.It worked . :D


Thx & Regarsd
Drop in the ocean.

Kowalski
06-29-2005, 12:25 PM
the same thing happened to me when i wrote my first CF application.
this implementation is better than relative paths. i mean if you want to use root path, you have to call getroot(), but since you dont write anything as a path, i mean you only write the file name, this means there is no path, the file is right on the root