9

I want to install my database to a separate folder (@ C:\Users\User1\AppData\Roaming\Company1\database.mdb)

I'm using a C# setup project.

How can I do it?

aF.
  • 64,980
  • 43
  • 135
  • 198
Mike Bryant
  • 2,455
  • 9
  • 39
  • 60

3 Answers3

8
  1. Right-click on the project and select View -> File System
  2. in the new File System screen, right-click the root node (File System on target Machine) and select Add Special Folder -> User's Application Data Folder
  3. Select the newly added folder form the treeview and create any sub-folder structure you need
  4. Finally select your destination folder, right-click, Add -> File and select the .mddb file.
Strillo
  • 2,952
  • 13
  • 15
  • 1
    I tried that but got File '' should not be installed into a User's Profile folder because it may not be available to all users No sign of my database anywhere in the app data folder/ subfolders – Mike Bryant Dec 02 '11 at 10:25
  • It does work I thought that when i right clicked and install that it automatically re generated the setup file but no. – Mike Bryant Dec 02 '11 at 10:41
6

Right click on your Setup project -> View -> File System. Then you could add a custom folder and set its default location to [CommonAppDataFolder]:

enter image description here

Then add your database file to this folder.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
5

Just for completeness, here is the official documentation for changing the folders: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/716bxh4e(v=vs.100)

  1. To add a custom folder that targets a predefined Windows folder In the folder list of the File System Editor, select the File System on Target Machine node.
  2. On the Action menu, point to Add Special Folder, and then click Custom Folder. The new folder is highlighted in the folder list.
  3. Type a name for the custom folder. For example, to target the Temp folder, type "Temp Folder".
  4. In the Properties window, select the DefaultLocation property and enter the Windows Installer system folder property for the folder you wish to target. For example, the property for the Temp folder is [TempFolder]. For a list of system folder properties supported by Windows Installer, see System Folder Properties.

Here is a list of all folder properties: https://learn.microsoft.com/en-us/previous-versions//aa372057(v=vs.85)?redirectedfrom=MSDN

Property Description
AdminToolsFolder The full path to the directory that contains administrative tools.
AppDataFolder The full path to the Roaming folder for the current user.
CommonAppDataFolder The full path to application data for all users.
CommonFiles64Folder The full path to the predefined 64-bit Common Files folder.
CommonFilesFolder The full path to the Common Files folder for the current user.
DesktopFolder The full path to the Desktop folder.
FavoritesFolder The full path to the Favorites folder for the current user.
FontsFolder The full path to the Fonts folder.
LocalAppDataFolder The full path to the folder that contains local (nonroaming) applications.
MyPicturesFolder The full path to the Pictures folder.
PersonalFolder The full path to the Documents folder for the current user.
ProgramFiles64Folder The full path to the predefined 64-bit Program Files folder.
ProgramFilesFolder The full path to the predefined 32-bit Program Files folder.
ProgramMenuFolder The full path to the Program Menu folder.
SendToFolder The full path to the SendTo folder for the current user.
StartMenuFolder The full path to the Start menu folder.
StartupFolder The full path to the Startup folder.
System16Folder The full path to folder for 16-bit system DLLs.
System64Folder The full path to the predefined System64 folder.
SystemFolder The full path to the System folder for the current user.
TempFolder The full path to the Temp folder.
TemplateFolder The full path to the Template folder for the current user.
WindowsFolder The full path to the Windows folder.
WindowsVolume The volume of the Windows folder.

When using them, make sure to use the square brackets [] around the property names.

Ksdmg
  • 397
  • 5
  • 15
  • 3
    You really should add the most relevant parts of your linked resources to your answer. Web resources change sooner or later and might not be available any longer. This is very true for Microsoft pages. – Andreas Jan 26 '21 at 14:41
  • 1
    @Andreas I have added the related information as you suggested, to make the answer complete. – Ksdmg Jan 27 '21 at 10:19