Tuesday, November 23, 2010

How to get the path of AppData for an application?

Often in windows OS, a separate directory is created for an application for a user for saving user-specific information and user has the administrative right on that folder. Recently, I was working on a project with winxp platform. While client was testing the same software on win 7 , he found that the application failed to create the or modify a file in the system directory where the application was loaded. So, then the concept of Appdata came and I implemented the solution using the link provided by client.
Here is the link
http://stackoverflow.com/questions/946420/allow-access-permission-to-write-in-program-files-of-windows-7
And here is my code for getting the AppData folder

XmlDocument xmldoc = new XmlDocument();

string xmlfilepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

//loading the file
xmldoc.Load(xmlfilepath + "/" + "enstatics.xml");
//returning the xmldoc
return xmldoc;

No comments:

Post a Comment