Colleagues, subject line says it.
Details:
1. Code:
2. MS VS 2019 on-line Help states (ref.
" Read(Char[], Int32, Int32)
Reads a specified maximum of characters from the current stream into a buffer, beginning at the specified index."
3. On the very 1st iteration of the cycle, this Exception was thrown (dimensions in the red ink):
So, the file is twice as long as buffer (Char array, 16 Mb), the starting point (or "index") to read from is 4K. I tried this code with the Char array reduced to 1 Mb, even to 16 Kb - the outcome was the same: this same exception thrown.
What am I doing wrong?
Please review and advise, AHWBGA!
Regards,
Ilya
Details:
1. Code:
Code:
Do While liEndPos = 0
If liEndPos > 0 Then
liEndPos -= 1
End If
ReDim laChars(liArrLen)
loStreamReader = New StreamReader(tcSrcFile)
loStreamReader.Read(laChars, liStartPos, liArrLen)
lsReadStr = CompilerServices.Conversions.FromCharArray(laChars)
' There can be NULLs at the end of the array, let's clean 'em out
For I As Int32 = laChars.Length - 1 To 0 Step -1
If IsNothing(laChars(I)) Or laChars(I) = vbNullChar Then
ReDim Preserve laChars(I - 1)
End If
Next
liEndPos = InStrRev(lsReadStr, tsEndDelim, CompareMethod.Text)
My.Computer.FileSystem.WriteAllText(tcOutFile, lsReadStr, True)
Loop
2. MS VS 2019 on-line Help states (ref.
" Read(Char[], Int32, Int32)
Reads a specified maximum of characters from the current stream into a buffer, beginning at the specified index."
3. On the very 1st iteration of the cycle, this Exception was thrown (dimensions in the red ink):
So, the file is twice as long as buffer (Char array, 16 Mb), the starting point (or "index") to read from is 4K. I tried this code with the Char array reduced to 1 Mb, even to 16 Kb - the outcome was the same: this same exception thrown.
What am I doing wrong?
Please review and advise, AHWBGA!
Regards,
Ilya