// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
Dim fsSource As New FileStream(StoragePath & DocumentName, FileMode.Open, FileAccess.Read)
' Read the source file into a byte array.
Dim bytes As Byte() = New Byte(fsSource.Length - 1) {}
Dim numBytesToRead As Integer = CInt(fsSource.Length)
Dim numBytesRead As Integer = 0
While numBytesToRead > 0
' Read may return anything from 0 to numBytesToRead.
Dim n As Integer = fsSource.Read(bytes, numBytesRead, numBytesToRead)
' Break when the end of the file is reached.
If n = 0 Then
Exit While
End If
numBytesRead += n
numBytesToRead -= n
End While
numBytesToRead = bytes.Length