I wanted to have an application remove a targeted file from specified worksations. The user executing the software would be an admin on the target machine so I used the following code for a test:
string strTarget = @"\\" + textBox1.Text + @"\C$\Temp\temp.txt";
try
{
File.Delete(strTarget);
}
catch (Exception ex)
{
MessageBox.Show("Failure to delete: " + ex.Message);
}
I then created a \Temp\Temp.txt file on both my own workstation and another test machine. I am an admin on both machines and can manually access and delete the file through the UNC path in question. When I ran the code debugger no exceptions are thrown, but the file doesn't delete. I can't figure our what is not happening for this to fail.
Is there anything I can check or any code I need to add? I've done a search on other questions, but I havn't been able to find an answer yet.