I check if the 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 message
The process cannot access the file '[my file path is here]' because it is being used by another process.
There is no File.Close(myPath) that I can name so that it is closed after creation, so how do I free this resource so that I can open it later in my program?
c # file-io
John 01 Mar. 2018-11-11T00: 00Z
source share