开发者

.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 '开发者_C百科\\users.xml'.").

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


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");


Here is how to do it in VS2005. It deploys the file along with the project.
This is for a native application - it should be similar for a managed one.

Content field specifies whether to deploy the file to the target. The file is deployed to the same directory as the application. I am not sure how VS2005 handles the deployment in case you updated the file, meaning you might need to manually delete it on the device.

VS2005 http://www.freeimagehosting.net/uploads/255e2922df.jpg


You can try adding the file to your application, setting "Build Action" to content, and enabling "Copy to Output Directory". Also, I believe there's an option in emulator preferences which enables sharing files between emulator and the host OS.


Go to File->Configuration on the emulator and share a directory from PC. This directory becomes your storage card so if you put a file there like test.csv then you can read it from "Storage Card\test.csv" in the program. (I am using VS2008 and Windows Mobile 5.0 Pocket PC RC 2 emulator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜