|
-
Mar 20th, 2002, 01:20 PM
#1
Thread Starter
Addicted Member
Searching/Editing Textfile
Hi
I am writing a piece of code using the FileSystemObject... it copies a plain text file... however, I need to search for a string in that text file and replace it (in the copied version) with another string and I have absolutely no idea how to do this... any ideas? I can copy the file, just not search & edit it
Thanks,
Adam
-
Mar 20th, 2002, 01:37 PM
#2
Frenzied Member
Here is a solution, read the file in to a string variable, then do a replace on the string and then write the string to the new file.
VB Code:
'open your file, etc
strFile = f.ReadAll
strFile = Replace(strFile, "whatever", "new stuff")
'write strFile back to the new file
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Mar 20th, 2002, 01:51 PM
#3
Thread Starter
Addicted Member
Will that replace just the first match, or all of them?
Either way, thanks
Adam
-
Mar 20th, 2002, 03:59 PM
#4
Frenzied Member
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

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
|