I am trying to modify this function that load an external file.
Instead of it writing bit by bit to the 'Stream' IOStream, I would like to write the data to a temporary MemoryStream, and then write it to 'Stream' all at once. This should be right before the 'Stream.Close()' line.
Can you help me ?
Here is my current code:
Code: Select all
Dim FromStream As System.IO.Stream = Nothing
FromStream = GetFileStream(Path)
If Not FromStream Is Nothing Then
Const Size As Integer = 256 * 1024
Dim buffer(Size) As Byte
Dim ReadBytes As Integer
ReadBytes = FromStream.Read(buffer, 0, Size)
If ReadBytes = 0 Then Exit While
Stream.Write(buffer, 0, ReadBytes)
Catch e As System.IO.IOException
' Loading is interrupted
Handled = True