Is there a way to read large text file in parts?
c#
Solution
How do you read the file right now ? You could use the StreamReader class, and read the file line by line (ReadLine method). You could also read a specified amount of bytes from the file on each read operation (Read method)
Problem
I have a large file(60mb) and I am reading the file into a string and Iam returning that string to another method. Now when I am reading the file into a string its giving System out of memory exception. Is there a way to read file in parts and append it to the string? If not is there a way around this? ``` static public string Serialize() { string returnValue; System.IO.FileInfo file1 = new FileInfo(@"c:\file.txt"); returnValue = System.IO.File.ReadAllText(file1.ToString()); } ```