+ Reply to Thread
Results 1 to 2 of 2

Thread: Replace Text inside txt file

  1. #1

    Replace Text inside txt file

    I am having issue replacing text inside a textfile , any idea how can i do that ?
    Last edited by csharpmaster; 11-11-2012 at 09:34 AM.

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    28
    Steps :
    1) retrieve the text
    2) replace it
    3) write it back to txt file

    Snippet :
    Code:
        string path = "file.txt";
    
        string replace = File.ReadAllText(path);
        replace = replace.Replace("word1", "word2"); // replace word1 by word2
        File.WriteAllText(path, replace);
    Best Regards.

+ Reply to Thread

Tags for this Thread

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