Created
July 30, 2012 16:16
-
-
Save bobbychopra/3208145 to your computer and use it in GitHub Desktop.
File Reader: does not throw process is using file error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DO THIS | |
using (var filestream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | |
using (var reader = new StreamReader(filestream)) | |
{ | |
records = reader.ReadToEnd(); | |
reader.Close(); | |
} | |
//// NOT THIS | |
//using (var reader = new StreamReader(filePath)) | |
//{ | |
// records = reader.ReadToEnd(); | |
// reader.Close(); | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment