I have code running that needs to access a file that cannot be accessed without administrator permissions. When I run my app as administrator, there is no problem. When I run it normally, I get an "Access is denied" error. I would prefer to not have the entire app require administrative permissions unless this functionality is utilized.
I am running the methods needing administrative access through a background worker. Is there a way for just the background worker or this group of methods to request administrative access? The class actually accessing the file is ZipFile, so if there's a way to request the permissions there, that is also an option.
Thank you. Below is the code that throws an error if not running the app as administrator. The code is opening an existing .zip file, modifying a file within the zip, then saving the zip.
using (var zip = new ZipFile(filePath))
{
zip.UpdateEntry("file.xml", theXElement.ToString(), encoding: Encoding.UTF8);
zip.Save();
}