All Forums >> [Scripting] >> Post a VBScript >> Convert a file to a string Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
You might think that it sounds simple, but take an HTA for example. Say that you just created this monster .HTA file, but don't want to copy it out along with your other script(s) to the pc it will be running on. You want to create it on the fly. Like for using a .HTA for a progress bar? Well, you could manually enter in hundreds of lines of code, remembering to wrap them in special quotes and characters so that when you write the lines out to a text file, it will be formatted correctly. OR, you could use this function: (just copy and paste it into your script, it already includes the required class for concatenating the strings). each line is wrapped in double quotes, and I use Chr(34) for the internal quotes.
Hope you find this as usefull as I do.
For an example of how this works, here is the raw text of an HTA file:
And here is the modified text of that hta, which is returned ina single string, each line seperated by a VbCrLf:
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers)
"It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury