Created
October 5, 2018 04:23
-
-
Save arnabdas/fa31abb02f31fb3a192c353e86615687 to your computer and use it in GitHub Desktop.
Read a large file and write the processed data into a stream
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
| // https://stackoverflow.com/questions/2161895/reading-large-text-files-with-streams-in-c-sharp | |
| // https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-write-text-to-a-file | |
| using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | |
| using (BufferedStream bs = new BufferedStream(fs)) | |
| using (StreamReader sr = new StreamReader(bs)) | |
| using (StreamWriter outputFile = new StreamWriter(Path.Combine(mydocpath,"WriteLines.txt"))) | |
| { | |
| string line; | |
| while ((line = sr.ReadLine()) != null) | |
| { | |
| outputFile.WriteLine(line); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment