Text file reading / writing

  • Thread starter Thread starter Barry McGuire
  • Start date Start date
Hi, Barry McGuire,

You should look at the System.IO namespace. For text files the most
appropriate methods are the static methods OpenText, CreateText and
AppendText on the System.IO.File class:

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemIOFileClassOpenTextTopic.asp
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemIOFileClassCreateTextTopic.asp
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemIOFileClassAppendTextTopic.asp

There are examples in each of the topics that will be of help to you.

Just make sure you:
- Set enough rights for the account the code is executed with (usually
ASPNET or NETWORK SERVICE) for the files/folders you work with
- Close the streams (stream reader or stream writer) after you finish
reading/writing.

Hope this helps
Martin
 
Back
Top