2
  • I have to find a suitable location to deploy my SDF (database) file.
  • The file must be the same to all users
  • Windows applications can't write to the ProgramFiles folder.
  • One user can't access other user's AppData folder
  • A good choice would be %ProgramData%
  • In Visual Studio Setup Project File System view, when I right click the output folders I don't have the %ProgramData% option

How to write to that folder?

1

2 Answers 2

1

Check this out:

Specifying c:\ProgramData folder in Setup project?

Winforms Deployment

string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

CommonApplicationData is C:\ProgramData on Windows > Vista, and something like C:\Documents and Settings\All Users on XP.

Sign up to request clarification or add additional context in comments.

1 Comment

I suppose that should be Environment.SpecialFolder.CommonApplicationData for the %ProgramData% folder.
1

Actually this question is a duplicate. Here is the real way tell VDPROJ to deploy to that location:

Writing to AppData from a Setup & Deployment Project

But that will leave another problem: Standard Users won't have write privs to that directory. You'll either have to write a custom action to open it up or you'll have to use a better MSI authoring tool such as Windows Installer XML (open source) or InstallShield 2010LE ( free ) that has proper support for defining resource permissions.

2 Comments

normal users also don't have permission to install new programs. So I don't think it would be a problem, since probably the installer will be running with admin permissions.
What I am saying is an Admin will install your application but when a standard user ( or an admin with UAC enabled ) runs code that tries to write to your database it will throw an exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.