You can start your application again with elevated permission and have some check at the application's start to see if this is the case. Here's an example: (Be careful not to get into an endless loop of the application starting itself.)
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1 && args[1] == "-e") Text = "Elevated";
}
private void button1_Click(object sender, EventArgs e)
{
Process process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = Application.ExecutablePath,
Arguments = "-e",
Verb = "runas",//-Admin.
}
};
process.Start();
}
}
I agree, though, that storing information in "C:" is probably not a good idea. You can try someplace like: Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
.