Skip to content

Instantly share code, notes, and snippets.

@bobbychopra
Created July 30, 2012 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbychopra/3208145 to your computer and use it in GitHub Desktop.
Save bobbychopra/3208145 to your computer and use it in GitHub Desktop.
File Reader: does not throw process is using file error
// 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