Text file reading / writing

  • Thread starter Thread starter Barry McGuire
  • Start date Start date
B

Barry McGuire

Does anyone have any ASP.NET code for reading or writing to/from text files?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top