Results 1 to 3 of 3

Thread: [2005] Write text file

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    38

    Resolved [2005] Write text file

    Hello!

    What is the fastest choice for writing text file from script.
    Should I use IO.File.WriteAllText or System.IO.StreamWriter or something else?
    Last edited by BinnyGreen; Mar 11th, 2008 at 12:10 PM.

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: [2005] Write text file

    StreamWriter is my choice
    Microsoft Techie

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Write text file

    You should use WriteAllText if you have a single string that you want to write to a file. WriteAllText will create the StreamWriter, write the string and then close the file internally. There's no point doing it yourself when it can be done for you with a single line of code. If what you want to write is more complex then it may be worthwhile creating a StreamWriter explicitly but I rarely find the need. WriteAllText, WriteAllLines and AppendAllText are simple and all you need in the vast majority of cases.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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