|
-
Mar 5th, 2008, 02:30 AM
#1
Thread Starter
Member
[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.
-
Mar 5th, 2008, 04:12 AM
#2
Fanatic Member
Re: [2005] Write text file
StreamWriter is my choice
-
Mar 5th, 2008, 04:18 AM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|