Reputation: 848
In my winforms application I have some code that saves a datagridview/datatable to an XML in the application.startuppath that will usualy be "C:\Program Files(x86)\MyApplication\export.xml but i'm getting an error that it don't have the rights to save this XML file.
When running the application with administrator rights it has no problem.
How can I fix this without needing admin rights?
I'm using this code
string xmlPath = Application.StartupPath + @"\export.xml";
DS1.WriteXml(xmlPath, XmlWriteMode.WriteSchema);
Upvotes: 0
Views: 2403
Reputation: 1919
Unless your application is made to run in Administrator mode, I wouldn't touch that folder.
You can use "My Documents/yourapp" or under AppData.
Upvotes: 0
Reputation: 157146
You need admin rights to write to that folder. There is no way to circumvent that (without disabling UAC).
The only decent solution is: Write to another folder.
Upvotes: 1