CHAPTER 16 THE SYSTEM.IO NAMESPACE 531 (Free web hosting with ftp) static
CHAPTER 16 THE SYSTEM.IO NAMESPACE 531 static void Main(string[] args) { // Display info about boot.ini and then open // for read-only access. FileInfo bootFile = new FileInfo(@”C:boot.ini”); Console.WriteLine(bootFile.CreationTime); Console.WriteLine(bootFile.LastAccessTime); FileStream readOnlyStream = bootFile.OpenRead(); readOnlyStream.Close(); } The Abstract Stream Class At this point, you have seen numerous ways to obtain FileStream, StreamReader, and StreamWriter objects, but you have yet to read data from, or written data to, a file using these types. To understand how to do so, you ll need to become familiar with the concept of a stream. In the world of I/O manipulation, a stream represents a chunk of data. Streams provide a common way to interact with a sequence of bytes, regardless of what kind of device (file, network connection, printer, etc.) is storing or displaying the bytes in question. The abstract System.IO.Stream class defines a number of members that provide support for synchronous and asynchronous interactions with the storage medium (e.g., an underlying file or memory location). Figure 16-6 shows a few descendents of the Stream type. Figure 16-6. Stream-derived types Note Be aware that the concept of a stream is not limited to files or memory locations. To be sure, the .NET libraries provide stream access to networks and other stream-centric abstractions. Again, Stream descendents represent data as a raw stream of bytes; therefore, working with raw streams can be quite cryptic. Some Stream-derived types support seeking, which refers to the process of obtaining and adjusting the current position in the stream. To begin understanding the functionality provided by the Stream class, take note of the core members described in Table 16-6.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.