Though this option is not available in the DefaultLocation ComboBox, you could manually give [CommonAppDataFolder] option. Once you give this option the Custom folder will be copied to the ProgramData folder.
But the folder or files created this way are only Read-only permission. To make the folder/files writeable permission as well, I used alternate approach. I used installer file instead of the above. Below is the code sample to give folder and files full access control.
[RunInstaller(true)]
public partial class Installer1 : Installer
{
private string fullPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\YourFolder";
public override void Install(IDictionary savedState)
{
base.Install(savedState);
//Add custom code here
if (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(fullPath);
// Create files on inside the folder to make them writable
...
}
// https://stackoverflow.com/questions/9108399/how-to-grant-full-permission-to-a-file-created-by-my-application-for-all-users
DirectoryInfo dInfo = new DirectoryInfo(fullPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit,
PropagationFlags.NoPropagateInherit, AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
//Add custom code here
if (Directory.Exists(fullPath))
{
Directory.Delete(fullPath, true);
}
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
//Add custom code here
}
public override void Uninstall(IDictionary savedState)
{
Process application = null;
foreach (var process in Process.GetProcesses())
{
if (!process.ProcessName.ToLower().Contains("yourprocessname"))
continue;
application = process;
break;
}
if (application != null && application.Responding)
{
application.Kill();
base.Uninstall(savedState);
}
if (Directory.Exists(fullPath))
{
Directory.Delete(fullPath, true);
}
}
}