KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have tried to create a custom action for a Visual Studio Installer project to modify the permissions for a config file. The Installer.cs is as follows: public override void Commit(IDictionary savedState) { base.Commit(savedState); // Get path of our installation (e.g. TARGETDIR) //string configPath = System.IO.Path.GetDirectoryName(Context.Parameters["AssemblyPath"]) + @"\config.xml"; string configPath = @"C:\Program Files\Blueberry\Serial Number Reservation\config.xml"; // Get a FileSecurity object that represents the current security settings. FileSecurity fSecurity = File.GetAccessControl(configPath); //Get SID for 'Everyone' - WellKnownSidType works in non-english systems SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null); // Add the FileSystemAccessRule to the security settings. fSecurity.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)); // Set the new access settings. File.SetAccessControl(configPath, fSecurity); } public override void Install(IDictionary stateSaver) { base.Install(stateSaver); } public override void Rollback(IDictionary savedState) { base.Rollback(savedState); } public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); } Then I add the Primary Output (Installer class = true) into the Commit section of the setup project's Custom Actions. When I run the installer, I get the following error: Error 1001: Could not find file 'c:\mypath\myapp.InstallState' Scouring the web I've found a few examples of similar experiences, but none of the solutions offered have worked for me. Any ideas?
Tags (comma-separated)
Save Edits
Cancel