Installing Files to Public Documents Folder

Aug 21, 2015 at 5:21 PM
What is the proper way to install to the CommonDocuments location? i.e. C:\Users\Public\Documents

There doesn't seem to be any environment/sessions variables available for this location.
Coordinator
Aug 23, 2015 at 2:22 AM
Edited Aug 23, 2015 at 2:23 AM
Correct, there is none.

It is not a typical deployment story to install something into this folder. It is designed to be populated with the files created by users or applications but not by the setup application. That is why MSI (not Wix#) doesn't define the name/variable (like 'DesktopFolder') for this folder. See the full reference here:
AdminToolsFolder
AppDataFolder
CommonAppDataFolder
CommonFiles64Folder
CommonFilesFolder
DesktopFolder
FavoritesFolder
FontsFolder
LocalAppDataFolder
MyPicturesFolder
PersonalFolder
ProgramFiles64Folder
ProgramFilesFolder
ProgramMenuFolder
SendToFolder
StartMenuFolder
StartupFolder
System16Folder
System64Folder
SystemFolder
TempFolder
TemplateFolder
WindowsFolder
WindowsVolume
AdminToolsFolder
AppDataFolder
CommonAppDataFolder
CommonFiles64Folder
CommonFilesFolder
DesktopFolder
FavoritesFolder
FontsFolder
LocalAppDataFolder
MyPicturesFolder
PersonalFolder
ProgramFiles64Folder
ProgramFilesFolder
ProgramMenuFolder
SendToFolder
StartMenuFolder
StartupFolder
System16Folder
System64Folder
SystemFolder
TempFolder
TemplateFolder
WindowsFolder
Though you can always place anything you want in this folder from the custom action:
var project =
    new ManagedProject(...

project.BeforeInstall += Project_BeforeInstall;
...
 

static void Project_BeforeInstall(SetupEventArgs e)
{
    string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "mydoc.txt");
    if (e.IsInstalling)
    {
        e.Session.SaveBinary("<embedded file ID>", file);
    }
}
Aug 25, 2015 at 7:58 PM
Thank you, Oleg. BTW- I'm loving Wix#. Very well done!
Coordinator
Aug 26, 2015 at 2:16 PM
Thank you mate 😊