MyFileStream.Read(Buffer, 0, CInt(FileSize - 1))
Try this for your Read:
MyFileStream.Read(Buffer, 0, 65536)
Sorry, that has no effect. I tried it just in case you were seeing something I did not.
A PDF larger than 65,536 bytes would only be partially loaded. It is not uncommon to have PDF larger than this in our application.
I would also need to adjust the prevous line that creates the size of the Buffer() byte variable.
Why did you pick 65,536 when Int.MaxValue is considerably larger?