views:

200

answers:

3

I´ve an desktop aplication using VS2005.

The application write a XML document into a application´s folder.

When a run with a administrator the application run OK, but when a run like simple user (haven´t access rights) I receive the access denied message error.

My application will be distributed to multiple users, and therefore could not make the release of access by windows explorer. Need access to be released when installing my application on the machine User

How i can solve this problem?

+1  A: 

You should have your application write files that belong to a user in that user's My Documents folder, not into the application's folder.

You can get the path to the My Documents folder using the .NET Framework with the following C# code:

var myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));

If the XML file is more like application settings, then use Environment.SpecialFolder.ApplicationData or a more appropriate special folder.

cfeduke
A: 

Consider using the user's AppData directory instead. You can use:

string appDataDir = Application.UserAppDataPath;
Wim Hollebrandse
A: 

I have to use the folder where the User to install the application, which is usually C: \ Program Files \ ...

My application will create the following architecture: C:\Program Files\CapProj\Data\ << where the XML files will be located >> C:\Program Files\CapProj\Imagens\ << images folder >>

The .EXE file will be in C:\Program Files\CapProj\CapProj.EXE

My application doesn´t use any databae system. This application only uses only XML files to store data, because this application will be distributed to many users in Brasil.

Does anyone have any more tips?

Thx for all!!!

Thiago de Castro