I have the following code in the page_Load function. When the page loads for the first time after starting Visual Studio, everything works fine.
But any other call to open a file after that returns IOException: "File is in use by another process"even when a file is opened directly in VisualStudio Solution, this error is returned (of course, not as an exception)
FileStream mailinglist_FileStream = new FileStream(@"\foobarFile.txt", FileMode.Open);
PeekingStreamReader mailinglist_Reader = new PeekingStreamReader(mailinglist_FileStream);
//Do some stuff with the file
mailinglist_FileStream.Close();
mailinglist_Reader.Close();
mailinglist_Reader.Dispose();
mailinglist_FileStream.Dispose();
Why is the file still locked? and why does Visual Studio completely restart the reset file? when checking file properties, he says:
Build action: Content
Copy to output directory: do not copy
I am only reading this file. can i do something similar adLockOptimisticso that multiple processes can access the file?