kee <ke***@kee.dynu.com> wrote in message news:<40**********@news.tm.net.my>...
Hi All,
I am trying to write binary data to a file, which is bmp image:
Open "d:\temp\test001.bmp" For Binary Access Write As #1
Put #1, 1, strImage
Close #1
*** strImage contains binary data
when i try to open the bmp it show invalid bitmap file.
a few thoughts...
Does the file exist already? If so it may be longer than what you
write.
You don't need the ", 1": Put #1,,strImage
Using strings for binary data is good for VB3 and earlier but starting
with VB4 you get ansi/unicode translations going on and that may be
affecting you. Use a byte array instead of a string for binary data.
How are you getting the data? My guess is that's where it is getting
corrupted.
BTW, you should use the FreeFile function rather than hard-coding #1