i am having a problem using files in my c# aspx prog. take a look at the code snippet
filepath is a string containing the filepath. as you can see, i've done everything i can to release the file, but it's still open. i break the program after this by throwing an exception, so i can check the status of any processes on this file on my server, and 90% of the time it's still open.
i need to release this file so i can delete it a little further down my code. how can i do this? alternativly, how can i force a delete?
Code:
ArrayList fcontents = new ArrayList();
{
StreamReader sr = new StreamReader(filepath);
while(sr.Peek() != -1) fcontents.Add(sr.ReadLine());
sr.DiscardBufferedData();
sr.Close();
((IDisposable)sr).Dispose();
}
filepath is a string containing the filepath. as you can see, i've done everything i can to release the file, but it's still open. i break the program after this by throwing an exception, so i can check the status of any processes on this file on my server, and 90% of the time it's still open.
i need to release this file so i can delete it a little further down my code. how can i do this? alternativly, how can i force a delete?