Text File Stream Methods


The System.IO.File class provides several handy methods for working with text files. The following table summarizes these methods.

Open table as spreadsheet

Method

Purpose

AppendText

Creates a text file or opens it for appending if it already exists. Returns a StreamWriter for writing into the file.

CreateText

Creates a text file, overwriting it if it already exists. Returns a StreamWriter for writing into the file.

Exists

Returns True if a file exists. It is better practice (and much faster) to only try to open the file if Exists returns True, rather than just trying to open the file and catching errors with a Try Catch block.

OpenText

Opens an existing text file and returns a StreamReader to read from it. This method throws a FileNotFoundException if the file doesn’t exist.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net