c# - How to read a large (5GB) txt file in .NET?Swagat P10yAsked Aug 31, 2016, 7:14 AM54kVisual Basic .NETc# - How to read a large (5 GB) txt file in .NET?
ESEdney Silva6y agoPosted Mar 26, 2020, 10:18 AMDON´T POST SUPID THINGS!!!! READ VERY MUCH AND LEARN FIRST!!!!-1
Swagat P10y agoPosted Sep 7, 2016, 3:47 AMGuys here is the Solutionspublic static void fileReading(string path){IEnumerable lines = File.ReadLines(path);foreach (var item in lines){Regex.Split(item, "\r\n");Console.WriteLine(item);}Console.ReadLine();}0
Swagat P10y agoPosted Sep 1, 2016, 1:06 AMGuys Please don't post such answer without doing any R&D...Do not just copy and paste the answer from google.I already mentioned its 5GB data text file. Just think out of BOX.+1
Manas Mohapatra10y agoPosted Sep 1, 2016, 12:58 AMUse BufferedStream: using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (BufferedStream bs = new BufferedStream(fs)) { using (StreamReader sr = new StreamReader(bs)) { string line; while ((line = sr.ReadLine()) != null) { } } } } http://cc.davelozinski.com/c-sharp/fastest-way-to-read-text-files+1
Vinay Singh10y agoPosted Sep 1, 2016, 12:16 AMHi check this linkhttp://stackoverflow.com/questions/4273699/how-to-read-a-large-1-gb-txt-file-in-net0
Akash Varshney10y agoPosted Aug 31, 2016, 7:22 AMyou can use MemoryMappedFilewhich is used for that type of scenariohttps://msdn.microsoft.com/en-us/library/system.io.memorymappedfiles.memorymappedfile.aspx-1
Edney SilvaPosted Mar 26, 2020, 10:18 AM
Swagat PPosted Sep 7, 2016, 3:47 AM
{
IEnumerable
foreach (var item in lines)
{
Regex.Split(item, "\r\n");
Console.WriteLine(item);
}
Console.ReadLine();
}
Swagat PPosted Sep 1, 2016, 1:06 AM
Manas MohapatraPosted Sep 1, 2016, 12:58 AM
Vinay SinghPosted Sep 1, 2016, 12:16 AM
Akash VarshneyPosted Aug 31, 2016, 7:22 AM
you can use MemoryMappedFilewhich is used for that type of scenario