I check to see if a file exists with
if(!File.Exists(myPath))
{
File.Create(myPath);
}
However, when I go to create a StreamReader
with this newly created file, I get an error saying that
The process cannot access the file '[my file path here]' because it is being used by another process.
There isn't a File.Close(myPath)
that I can call so that it is closed after being created, so how do I free this resource so that I can open it later in my program?