"c# read large file" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c# read large file" answered properly. Developers are finding an appropriate answer about c# read large file related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c# read large file. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c# read large file.
c# read huge file
class Program
{
static void Main(String[] args)
{
const int bufferSize = 1024;
var sb = new StringBuilder();
var buffer = new Char[bufferSize];
var length = 0L;
var totalRead = 0L;
var count = bufferSize;
using (var sr = new StreamReader(@"C:\Temp\file.txt"))
{
length = sr.BaseStream.Length;
while (count > 0)
{
count = sr.Read(buffer, 0, bufferSize);
sb.Append(buffer, 0, count);
totalRead += count;
}
}
Console.ReadKey();
}
}
Source: stackoverflow.com
c# read large file
int filesize = (new FileInfo(filePath)).Length;
using (Stream sr = File.OpenRead(filePath))
{
int maxchunk = 1024;
for(long x = 0; x < totalChunk; x++ )
{
long LefttotalLegth = filesize - (x * maxchunk);
long leghtcopy = Math.Min(maxchunk, LefttotalLegth);
byte[] chunkbyte = new byte[leghtcopy];
sr.Read(chunkbyte, 0, chunkbyte.Length);
//Do something after read. like write to file
}
}
All those coders who are working on the C# based application and are stuck on c# read large file can get a collection of related answers to their query. Programmers need to enter their query on c# read large file related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# read large file for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c# read large file while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c# read large file". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# read large file resolved professionally and stay updated to the latest C# updates.