+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 1969
    Posts
    237

    Default Replace Text in a Text File

    I have a Text file and need to replace some data in each line (Row Length is 55) from this Text File. Need to Replace Data from Position 11-19 on each Row, - 9 digits with something else like 123456789 (some random nos).

    Please help me with code

    <%
    Set fs=Server.CreateObject("Scripting.FileSystemObject ")

    Set f=fs.OpenTextFile(Server.MapPath("MyTextFile.txt") , 1)



    f.Close
    Set f=Nothing
    Set fs=Nothing
    %>

  2. #2
    Join Date
    Dec 1969
    Posts
    95,760

    Default

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=133

    So you have no choice but to read from one file and write to another.
    And just use string manipulation to change the line contents.

    example:
    Code:
    line = fromFile.readLine
    front = Left(line,10)
    back = Mid(line,20)
    line = front & "123456789" & back
    toFile.writeLine line
    And do that in a loop for the entire file.

Bookmarks

Posting Permissions

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


More ASP Resources

Resources:
-- ASP Articles
-- ASP.NET Information
-- 4Guys ASP F.A.Q.
-- ASPFAQs.com
-- ASP Coding Tips
-- Related Web Technologies
-- User Tips!!
-- ASP-related ListServs
-- HTML5 Development Center
-- JavaScripts


Smart Sites
-- Mobile Development Center
-- MSDN SpotLight
-- Web Dev Resource Center
-- Cloud Showcase for Developers


Windows Technology
Check out these Web sites for articles, tutorials, FAQs, discussions, and code on ASP and related technologies!
-- CodeGuru.com
-- VBForums.com
-- ASPFAQs.com
-- ASPMessageboard.com
-- DevX.com
-- Developer.com
-- FreeVBCode