Member Avatar for iamthwee

Following this
http://support.microsoft.com/kb/301070

So it works fine on text file, but fails on anything like word or excel files. Try it and you'll see!

Why? Does it need to read/written in binary.
Any help is greatly appreciated.

Member Avatar for iamthwee

Anyone?

Member Avatar for iamthwee

bump

Dim fsInput As New FileStream(sInputFilename, _
FileMode.Open, FileAccess.Read)
...
..
.
'Read the file text to the byte array.
Dim bytearrayinput(fsInput.Length - 1) As Byte
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length)

=============
The code is opening and reading a TEXT file. You have to open the file in BINARY mode and read the content from it.

READ BINARY FILE:
bytearrayinput = My.Computer.FileSystem.ReadAllBytes("C:\Test.Doc")

Hope it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.