Results 1 to 2 of 2

Thread: read, append to a text file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    read, append to a text file

    Hello,

    VS 2005

    What is the best and most efficient method for reading from a text file. Storing it in a temporary file or variable, and then finally appending it to another file.

    Its important the file that it is being appended to does not overwrite what is already in there.

    Many thanks for any advice,

    Steve
    steve

  2. #2
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Re: read, append to a text file

    Add at top of .cs file:
    VB Code:
    1. using System.IO;

    Reading:
    VB Code:
    1. string path = "C:/text.txt";
    2. string temp = File.ReadAllText(path);

    Appending:
    VB Code:
    1. File.AppendAllText(path, temp);

    Hope that helps



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

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