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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resource file question

Status
Not open for further replies.

Haazi2

Programmer
Aug 25, 2000
51
US
I understand how to retreive images and strings from a resource file but I'm having trouble retrieving a user defined file from a resource file does anyone have an example of how to retrieve such a resource from a resource file. Say for example you put a text file in a resource file.
 
I had the same problem with an avi file. Add your file as a "custom" resource and then pull it out like this. It should work. I've tried it on avi and fax cover page files. I usually put it in a function but you can do it either way.
Code:
Dim bytResFile() as Byte
Dim strNewFile As String

'set the path where you'll store the file.
strNewFile = App.Path & "somewhere.txt"

'only need to pull it out once so,
If(Dir(strNewFile) = "") Then

'Retrieve the resource file into a byte array
'make sure your resource id num is correct
bytResFile = LoadResData(101, "Custom")

'Open the output file
Open strNewFile For Binary Access Write As #1

'Write the resource to the file
Put #1, , bytResFile

'Close the file
Close #1
End If
'Now the file is on disk and you can use it however.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top