I have a C# Application that I’ve wrote. Everything works 100% besides one method. If UAC is turned on I can not save a file, not even the Settings.config. I tried using a manifest file, with no luck. What am I doing wrong?
public static void UpdateVersionText()
{
var wc = new WebClient();
var utf8 = new UTF8Encoding();
var list = utf8.GetString(wc.DownloadData("https://www.agentsarea.co.uk/photolibrary/photos/data/version.txt"));
wc.Dispose();
Properties.Settings.Default.version = list.Trim();
Properties.Settings.Default.Save();
}
Save the file to a better place. You are probably saving to the current directory, which is in /Program files/, which a normal user should not write to. Try saving to %appdata% (each Windows user has their own directory) or to %allusersprofile% (all users share the same directory).
You get either path by calling the following:
AppData for the current user:
All users profile directory: