Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with writing binary data

2 views
Skip to first unread message

Jon Davis

unread,
Aug 6, 1999, 3:00:00 AM8/6/99
to
Help! I'm trying to write a DLL that takes binary data (image data, such as
a GIF file) and writes it to disk. But it keeps inserting extra junk at the
beginning of the file. I'm not really sure what I'm doing. Using VB6.
Here's a snippet:

FileID = FreeFile
Open FullFileName For Binary Access Write As FileID
Put #FileID, 1, Data
Close FileID

I'm thinking there's probably another way of going about this, and it'd look
completely different (i.e. using the FileSystemObject or something). Any
ideas?

Thanks,
Jon Davis

Douglas Marquardt

unread,
Aug 6, 1999, 3:00:00 AM8/6/99
to
Hi Jon:

>But it keeps inserting extra junk at the
>beginning of the file. I'm not really sure what I'm doing. Using VB6.
>Here's a snippet:
>
> FileID = FreeFile
> Open FullFileName For Binary Access Write As FileID
> Put #FileID, 1, Data
> Close FileID


What data type is the variable 'Data' -- perhaps what you are getting is the
header information for the data type (variant perhaps?).


Doug.


Jon Davis

unread,
Aug 6, 1999, 3:00:00 AM8/6/99
to
"Data" is a variant, the contents of which is generated here:

FileID = FreeFile
Open FullFileName For Binary Access Read Lock Write As FileID
Data = Input(LOF(FileID), FileID)
Close FileID

Douglas Marquardt <no_...@dummy.com> wrote in message
news:OZ#0HVE4#GA.312@cppssbbsa03...

Douglas Marquardt

unread,
Aug 6, 1999, 3:00:00 AM8/6/99
to
Hi Jon:

>"Data" is a variant

Then the variant header data is what is getting written to the file. Try
assigning the data to a byte array (or perhaps string) and save that instead
or the variant (I can't recall off the top of my head which one, or both,
work with Put) -- that way you should not get any header data.

Doug.


Jon Davis

unread,
Aug 9, 1999, 3:00:00 AM8/9/99
to
That worked, thanks. I had this crazy idea that binary data was
incompatible with the string data type.

Jon


Douglas Marquardt <no_...@dummy.com> wrote in message

news:eLcL1GG4#GA.312@cppssbbsa03...

0 new messages