File conversions in VB...
GHoosdum
Icrontian
I'm working on something over here at work and we're encoding files into base-64. Unfortunately we can't convert back.
What our program does is this:
Allows user to browse for file (word/excel doc)
Uploads that file to the server.
Passes file to .Net COM object to convert to base-64
-> (We're in a VB 6 environment, utilizing just this one .Net COM object for the conversion - the COM object is one we created in VS.Net utilizing its conversion libraries)
virus scans base-64 file
stores base-64 file in the database
What we want to do is upon download of the file, convert it back into a readable word or excel document, and save it to the desktop. We can't find anything that gives us back our original document after it's endoced to base-64. We can convert to UTF-8, but then we get a string of gibberish when it's opened in Word.
Right now, we've taken all the middle steps out of the operation. In our test region on a desktop machine, we're simply converting a file into base-64 utilizing this COM object, then trying to convert that directly back into the original file. We can't get that to work.
Any ideas?
What our program does is this:
Allows user to browse for file (word/excel doc)
Uploads that file to the server.
Passes file to .Net COM object to convert to base-64
-> (We're in a VB 6 environment, utilizing just this one .Net COM object for the conversion - the COM object is one we created in VS.Net utilizing its conversion libraries)
virus scans base-64 file
stores base-64 file in the database
What we want to do is upon download of the file, convert it back into a readable word or excel document, and save it to the desktop. We can't find anything that gives us back our original document after it's endoced to base-64. We can convert to UTF-8, but then we get a string of gibberish when it's opened in Word.
Right now, we've taken all the middle steps out of the operation. In our test region on a desktop machine, we're simply converting a file into base-64 utilizing this COM object, then trying to convert that directly back into the original file. We can't get that to work.
Any ideas?
0
Comments
OK, now here's what's going on: instead of UTF-8, we're simply writing the byte array out to a file, using the same FileStream class we're using to pull the file out. It seems like it should work... but it doesn't. Information in the file is getting lost somewhere. I've opened the original file, and the file after decode both in Notepad, and text information, such as "EMBED Photoshop.Image.7" seems to be maintained just fine after the conversion and reconversion. However, other characters, like £ become corrupted to simpler characters, like #.
/me scratches head...
I'd appreciate any help, even if it's not in VB (I understand most languages) as long as it utilizes .Net it will work the same for us either way...
http://www.freevbcode.com/ShowCode.asp?ID=4520
http://www.pstruh.cz/tips/detpg_Base64.htm
(It was just a google search, so you might have seen that already)