Results 1 to 3 of 3

Thread: Replacing a String in Multiple Text Files

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    2

    Question Replacing a String in Multiple Text Files

    Hi VBForums,

    I have the following code which finds and replaces a string in a specified text file.

    Code:
    Dim FSO, InputFile, OutputFile
    Dim s As String
    FSO = CreateObject("Scripting.FileSystemObject")
    InputFile = FSO.OpenTextFile("c:\File.txt", 1)
    s = InputFile.ReadAll
    s = Replace(s, TextBox1.Text, TextBox2.Text)
    OutputFile = FSO.CreateTextFile("c:\File.txt", True)
    OutputFile.Write(s)
    I need the code to find and replace a string in multiple text files. I've looked into using the following code but I don't know how to overwrite the text file which is been read.

    Code:
    InputFile = FSO.OpenTextFile("c:\File.txt", 1)
    Any thoughts?

    Thanks,
    Sebkeh

  2. #2

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    2

    Re: Replacing a String in Multiple Text Files

    Code:
    InputFile = FSO.OpenTextFile("c:\*.txt", 1)
    *
    Last edited by Sebkeh; May 16th, 2013 at 05:48 AM.

  3. #3
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: Replacing a String in Multiple Text Files

    This looks more like VBScript to me, not exactly VB.net.
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width