Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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
    }                           
}     
 
PREVIOUS NEXT
Tagged: #read #large #file
ADD COMMENT
Topic
Name
2+8 =