Hi, I am writing a small app in C# and part of it is testing if it has permissions to write to a location. The code for the method is:
Code:
private void test_permissions()
{
FileInfo config2 = new FileInfo(local.Text + "\\cstest.txt");
config2.Create();
config2.Delete();
}
When I call the method, giving it a path that is accessible, it creates the file, but then throws an exception, the text it "The process cannot access the file 'C:\Users\Toby\Documents\cstest.txt' because it is being used by another process." If I try to manually delete the file while the program is still running I get a similar message from Windows (Vista Ultimate 32-bit if it helps), but when I close the program I can delete it. I can't work out why it locks the file.
Thanks for your help,
gandaliter