How to deploy database files with Visual Studio Setup Project?
Question
- 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?
Solution
Check this out:
Specifying c:\ProgramData folder in Setup project?
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.
OTHER TIPS
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.