File Enumerators

By: Jesse Miller

Most file Input and output operations are supported in the .NET Framework and are implemented in the System.IO name space. File stream class in the System.IO name space is used to write, read and close files. This class inherits from the abstract class Stream. Many of its properties and methods are also derived from the Stream class. To open an existing file or to create a new file, an object of the type File Stream should be created.

The File Mode, File Access, and File Share enumerations define constants that are used by some of the File Stream and the Isolated Storage File Stream constructors and some of the File. Open overloaded methods. These constants affect the way in which the underlying file is created, opened and shared.

File Mode Enumerator defines various methods for opening files. The File Mode enumerator parameter is specified in many constructors for the File Stream, Isolated Storage File Stream constructors, and in the Open methods of File and File Info to restrict how a file is opened. The parameters to File Mode checks whether a file is overwritten, created, or opened.

The members of the File Mode enumerator are Append, Create, Create New, Open, Open or Create, and Truncate. Append opens the file if it exists and places the cursor at the end of file, or creates a new file.

Create command creates a new file. Create New specifies to an opening system that it should open a file if it exists or else create a new file. Truncate should be used carefully as it deletes the data present in the file. It opens an existing file. When opened, the file should be truncated so that its size is zero bytes.

Unless you specify a File Access enumerator, the file gets opened for both reading and writing. This enumerator indicates whether you want to read data from the file, write to the file, or perform both the operations.

The members of the File Access enumerator are Read, Read Write, and Write.
File Share Enumerator contains constants for controlling the kind of access that the other File Stream constructors can have to the same file.

A typical use of this enumeration is to define whether two different applications can simultaneously read from the same file.

The members of the File Share enumerator are Inheritable, None, Read, Read Write, and Write.

Quick Note: Taking the Nonsense out of looking for the right spyware remover

If you really want to take the work out of looking for that right Spyware Protection from a go to the Internet and get a or a Free
Download, In order to prevent your vital information from being ripped from your computer get your Remover Today.

Inheritable allows a file handle to pass inheritance to the child processes. None declines sharing of a current file. Read allows opening of a file for the purpose of reading and writing, and write allows opening.

Top Searches on
Computers
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 

» More on Computers