Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening files in binary mode 1

Status
Not open for further replies.

IvanhoBlanc

Programmer
Oct 22, 2002
3
BE
In VB6 there is an possibility to open files in a binary mode for reading and writing byte by byte (Open myFile For Binary As #1). Is there in VBScript such a thing? When using the FileSystemObject it is only possible to open files for TextStream. Low value's or other non printable characters are ignored.

Has anyone some experience with this? Thanks in advance.
 
IvanDeWitte,

You can use adodb stream. Format the visual inspection output string like this.
Code:
binfilespec="d:\test\abc.exe"    'your input

set adodbstrm=createobject("adodb.stream") 
with adodbstrm
    .type=1 
    .open 
    .loadfromfile binfilespec
End With 

bstrm=adodbstrm.read
lbyte= lenb(bstrm) 
wscript.echo lbyte

'if the length is too long for echo, you can shorten by 
'using a some smaller number for upper limit lbyte
for i=1 to lbyte    'for complete formatting
sfbstrm=sfbstrm & right("0" & hex(ascb(midb(bstrm,i,1))),2) & " "
next
wscript.echo sfbstrm

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top