Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Convert a file to a string

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,32180
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
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!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Convert a file to a string - 3/10/2006 5:42:17 AM   
  DiGiTAL.SkReAM


Posts: 1171
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
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
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Convert a file to a string Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts