Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm Creating a setup for my windows application. In this application an XML can be edited. When I'm running the installed program, the XML file can be read but not edited unless i choose to run it as administrator, even though I made sure that the file is accessible to all users not only admins! any help?
Posted
Updated 27-Feb-12 8:50am
v2
Comments
wizardzz 27-Feb-12 14:50pm    
Tried to clarify your problem in the title.
OUEISJ 27-Feb-12 16:35pm    
thanks :)

For the case you've stored your XML-File in C:\Program Files Directory, you don't have permissions to write files in Program Folder.
Use c:\Users\USER\AppData\Roaming to store files.

or in the isolated Storage:

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.aspx[^]
 
Share this answer
 
v2
Comments
OUEISJ 27-Feb-12 16:28pm    
But i'm creating the setup in order to use it on other computers
wouldn't the application be able to modify the xml file after installation?
Dave Kreskowiak 27-Feb-12 17:09pm    
Since any code a user launched runs AS the user, it inherits the security token of the user that launched it. That means the application has the same permissions as the user. Users do not have permissions to Write to anything under Program Files.

Move your XML file to a more accessible location, such as CommonApplicationData. See the enumeration at http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx for more details.
You need to change the location of your XML file if it is should be editable. Here is how to get the proper location:

You can find a directory dedicated for application settings for a current user of "all users" directory. Use System.Environment.GetFolderPath:
http://msdn.microsoft.com/en-us/library/dd992682.aspx[^],
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx[^].

Depending on you choice, it will persist your application data on a per-user basis or make them common.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900