01.
Public
Sub
SaveBinaryFile(strFilename
As
String
, bytesToWrite()
As
Byte
)
02.
Dim
position
As
Integer
= 0
03.
04.
Using fsNew
As
FileStream =
New
FileStream(strFilename, FileMode.Create, FileAccess.Write)
05.
Do
06.
Dim
intToCopy
As
Integer
= Math.Min(4096, bytesToWrite.Length - position)
07.
Dim
buffer(intToCopy - 1)
As
Byte
08.
Array.Copy(bytesToWrite, position, buffer, 0, intToCopy)
09.
fsNew.Write(buffer, 0, buffer.Length)
10.
ProgressBar1.Value = ((position / bytesToWrite.Length) * 100)
11.
Application.DoEvents()
12.
position += intToCopy
13.
Loop
While
position < bytesToWrite.Length
14.
End
Using
15.
End
Sub