开发者

Rewriting the xml file in my application folder

Am using WPF-C#, when am closing my application i need to write some xml document. its located in my application folder (../Data/test.xml). its working while debuging. when i deploy my application cant able to acce开发者_运维技巧ss the xmlfile in the program files folder. how i can resolve this issue.. the following image is the exception http://img197.imageshack.us/i/errqu.jpg/


Your users cannot modify a file located in Program Files.

If you have a configuration file you want to modify, you need to store it in the user's own ApplicationData folder, e.g.:

C:\Users\Bill\AppData\Local\SoftCo Software Inc\SuperApp\appconfig.xml

If you want standard users to be able to modify this config file, then your installation program is supposed to grant Everyone Full Control to the file. Your installation program is known to be running as an administrator, so it will have permissions to change permissions.

But you should not do that; this allows one user to alter program settings that will affect another user. These settings should be per-user (and stored in %AppData%, which the user already will have access to).


It is because of Windows UAC. You can fix the issue either

  1. using Run As Administrator option, from right click menu in the application.
  2. Modify the AppManifest file.
  3. Change the file location user writable locations.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜