Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET compact framework - where to put files so that they are accessible to emulator

I have a .NET CF project. In the project directory I put a simple xml file (users.xml) which has to be read by the device. When I debug the application on device emulator and try to load the file from code, the Exception is thrown (FileNotFoundException "Could not find file '\\users.xml'.").

Is there a mechanism to automatically deploy also configuration files to a device emulator?

like image 211
cubesoft Avatar asked Oct 15 '22 04:10

cubesoft


1 Answers

You have you path set wrong in your code. After following the instruction of Shaihi or Sphynx to get Studio to deploy the file, the file is then in the folder with the application.

Based on the fact that you're getting an error that it cannot find "\users.xml" tells me that you're either telling it to specifically look in the root folder or you haven't specified a folder.

Windows CE requires that you provide a fully-qualified path, so your application should either use the full path it is deployed to (i.e. "\Program Files\MyApp\users.xml") or you need to construct the path:

Path.Combine(
  Path.GetDirectoryName(
   Assembly.GetExecutingAssembly().GetName().CodeBase
  ), "users.xml");
like image 171
ctacke Avatar answered Nov 03 '22 00:11

ctacke