views:

57

answers:

3

Hi.

My application is not supposed to perform any administrative tasks, so I want a normal User account to be able to run it. Only thing is, my application reads from and writes to a database file; if the user running Windows 7 (Or Vista) installs my app in drive C, the drive's default permission set configuration doesn't allow my app to write data.

How can I allow my app to write to C:, without requiring full administrative privileges?

A: 

The user by default should have write permissions to drive C:, if not, then you will need to change the directory you read from and write to, to the executing directory (C:/Program Files/Your App/) rather than the root of C:

You can get this by

String Path = Path.GetDirectoryName(Application.ExecutablePath);
LnDCobra
+1  A: 

If the database file exists at install time you can just grant the user write access to the file as part of the installation process (ordinary users do not have this permission by default). If the file needs to be created by the program the user running the program will need modify permissions on the c drive, which is not something that I would recommend.

klausbyskov
+1 - grant permissions on installation, and dont give running processes direct access to c drive.
Russell
This one appears to be the best approach for me. How do I change permissions at installation time using VS2008 Setup and Deployment project?
TheAgent
A: 

I'd suggest storing your db file in Documents and Settings / App data / your app / directory. It exists specifically for this purpose. Writing to C:/Program Files is not so good practice. If that's possible in your case, that is.

Sejanus