|
-
Aug 2nd, 2001, 06:02 AM
#1
Thread Starter
Lively Member
Store and output a binary file
How can I store a binary file in my program, and output it to a file later?
-
Aug 2nd, 2001, 06:33 AM
#2
Create a resource file. Start the Resource Editor from the tools menu (if you don't have it you have to first goto Add-Ins|Add-In Manager and start the VB6 Resource Editor add-in.).
Click the "Add Custom Resource..." button on the toolbar and browse to the file you want to add.
The resource is added with a new ID (probably 101) under a "CUSTOM" folder.
To write it back to disk use code simular to this:
Code:
Private Sub SaveIt(ByVal FileName As String)
Dim bArr() As Byte
Dim hFile As Integer
bArr = LoadResData(101, "CUSTOM")
hFile = FreeFile
Open FileName For Binary Access Write As #hFile
Put #hFile, , bArr
Close #hFile
End Sub
Best regards
PS. Funny avitar your using! You had me fooled for a second.
-
Aug 2nd, 2001, 06:38 AM
#3
PowerPoster
is this you mean?
VB Code:
Dim buff As String
Open "C:\Crsyb14.hlp" For Binary As #1
buff = String(LOF(1), Chr(0))
Get #1, 1, buff
Close #1
Open "C:\Crsyb15.hlp" For Binary As #1
Put #1, 1, buff
Close #1
regards,
-
Aug 2nd, 2001, 06:46 AM
#4
Originally posted by Chris
is this you mean?
VB Code:
Dim buff As String
Open "C:\Crsyb14.hlp" For Binary As #1
buff = String(LOF(1), Chr(0))
Get #1, 1, buff
Close #1
Open "C:\Crsyb15.hlp" For Binary As #1
Put #1, 1, buff
Close #1
regards,
The above will only read and write one byte. You shouldn't use strings either because they store two bytes for every character. Use a byte array instead.
-
Aug 2nd, 2001, 06:48 AM
#5
-
Aug 4th, 2001, 04:13 AM
#6
Thread Starter
Lively Member
hi, i just got back from a trip so i haven't tried out any of your code samples yet. thanks for replying. i'm just wondering if it is possible to store a byte array permanently in a program. Instead of loading it from a file every time I run a program, is it possible for it to be inside the program already? I'm asking this because if I give a program to other people, instead of sending them an executable and other data files, I just want to send them one file. again, thanks for helpinh.
-
Aug 5th, 2001, 03:28 AM
#7
Yes you can. Simply add them to a Resource File.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|