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?

Jader Dias
  • 88,211
  • 155
  • 421
  • 625
  • 1
    possible duplicate of [Writing to AppData from a Setup & Deployment Project](http://stackoverflow.com/questions/3562151/writing-to-appdata-from-a-setup-deployment-project) – Christopher Painter Jan 17 '11 at 13:30

2 Answers2

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.

Community
  • 1
  • 1
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
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.

Community
  • 1
  • 1
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • 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. – Jader Dias Jan 17 '11 at 14:53
  • 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. – Christopher Painter Jan 17 '11 at 16:12