File and Serial I/O Classes Summary

The following pages provide detailed information on the properties and methods for the various classes that implement both file and serial port input and output communications.

The File Class is designed specifically for managing disk files and disk file directories.  The StreamReader and StreamWriter Classes apply to both file and serial communications.

The tables below summarize the properties and methods for each Class, which are described in greater detail in the following sections.

File and Serial I/O Classes Properties & Methods, 1
File Class Member Type Description

File.ComputeCRC

Shared Function

Returns a CRC check code computed by reading though a file. Used to verify that a file has not been corrupted.

File.ComputeLength 

Shared Function

Returns the length of a file computed by reading through a file and counting the bytes. Used to verify that a file has not been corrupted.

File.Copy

Shared Method

Copies a single file on devices like the flash disk and ROMDISK.

File.CreateDirectory

Shared Method

Creates a file directory and the path to the directory.

File.DeleteDirectory

Shared Method

Deletes a single, empty file directory.

File.DeleteFile

Shared Method

Deletes a single file.

File.GetDirectories

Shared Method

Returns an array of strings containing the names of directories in a directory.

File.GetFiles

Shared Method

Returns an array of strings containing the names of files in a directory.

File.Length

Shared Function

Efficiently returns the length of a file based on its directory entry.

 

Table 19-63: File and Serial I/O Classes Properties & Methods, 2

StreamReader Member Type Description

New StreamReader

Constructor Method 

Opens a file or serial port device for reading.

streamreader_obj.Close

Method

Closes the file or device associated with a StreamReader Object.

streamreader_obj.Peek

Method

Returns the next byte from an input stream without removing it from the stream.

streamreader_obj.Read

Method

Returns the next byte from an input stream and removes it from the stream.

streamreader_obj.ReadLine

Method

Reads a line from the input stream terminated by LF, CR, or CR-LF.

 

Table 19-64: File and Serial I/O Classes Properties & Methods, 3

StreamWriter Member Type Description

New StreamWriter

Constructor Method

Opens a file or serial port device for writing.

streamwriter_obj.AutoFlush

Property

Sets or gets the property that controls whether or not output is buffered.

streamwriter_obj.Close

Method

Closes the file or device associated with a StreamWriter Object.

streamwriter_obj.Flush

Method

Immediately writes any buffered data for a StreamWriter Object.

streamwriter_obj.NewLine

Property

Sets or gets the property that controls how lines are terminated by the WriteLine method.

streamwriter_obj.Write

Method

Writes a number or a String to an output device or file.

streamwriter_obj.WriteLine

Method

Writes a number or a String to an output device or file, followed by the NewLine line terminator.