2
我正在使用一些範圍從1-2Gig的文本文件。我不能使用傳統的流媒體閱讀器,並決定閱讀chunck並做我的工作。問題是我不確定什麼時候到達文件的末尾,因爲它已經在一個文件上工作了很長時間,我不確定我可以通過緩衝區讀取多大的文件。這裏是代碼:閱讀大文本文件進行解析
dim Buffer_Size = 30000
dim bufferread = new [Char](Buffer_Size - 1){}
dim bytesread as integer = 0
dim totalbytesread as integer = 0
dim sb as new stringbuilder
Do
bytesread = inputfile.read(bufferread, 0 , Buffer_Size)
sb.append(bufferread)
totalbytesread = bytesread + totalbytesread
if sb.length > 9999999 then
data = sb.tostring
if not data is nothing then
parsingtools.load(data)
endif
endif
if totalbytesread > 1000000000 then
logs.constructlog("File almost done")
endif
loop until inputfile.endofstream
有沒有任何控制或代碼,我可以檢查多少文件仍然是?