Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess Denied When Attempting To Edit A File ProgramFiles
    primarykey
    data
    text
    <p>I am trying to edit a config file in the program files. These config files are used by Windows services. Here's the details:</p> <ul> <li>I can't change the location of the file to be edited</li> <li>UAC is OFF</li> <li>Just in case, the app.manifest has been edited so it runs as admin</li> </ul> <p>Here's the code:</p> <pre><code>public void UpdateDNSNameInConfigFile(string v, ConfigFileOption cf) { string ConfigFilePath = Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + @"\&lt;redacted&gt;\&lt;redacted&gt;"; string ConfigFileContents = string.Empty; string DNSName = v.Replace("/ucf:", ""); //Remove the command line arg from the value switch (cf) { case ConfigFileOption.CobanSystem: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.&lt;redacted&gt;System"; break; case ConfigFileOption.Agent_AVL: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.Agent.AVL"; break; case ConfigFileOption.Agent_DB: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.Agent.DB"; break; case ConfigFileOption.Agent_DVD: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.Agent.DVD"; break; case ConfigFileOption.Agent_FileAgent: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.Agent.FileAgent"; break; case ConfigFileOption.Agent_Log: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.Agent.Log"; break; case ConfigFileOption.Agent_Streaming: ConfigFilePath = ConfigFilePath + @"\&lt;redacted&gt;.Agent.Streaming"; break; case ConfigFileOption.Agent_Listener: throw new NotImplementedException(); case ConfigFileOption.Agent_InCar: throw new NotImplementedException(); case ConfigFileOption.Agent_Tape: throw new NotImplementedException(); } ConfigFileContents = File.ReadAllText(ConfigFilePath); ConfigFileContents = ConfigFileContents.Replace("&lt;redacted&gt;", v); File.WriteAllText(ConfigFilePath, ConfigFileContents); } </code></pre> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload