Search code examples
visual-studio-2010installationwindows-installersetup-projectvisual-studio-setup-proje

How to deploy database files with Visual Studio Setup Project?


  • 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?

    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.