Streams
A common programming task is to read data from or write data to files, network sockets, or some other devices. The BCL formalizes this behavior by means of an abstract class Stream (namespace System.IO). Table 5.2 shows some frequently used methods available on this class.
Method | Description |
---|---|
CanSeek | Can you seek to a position within the stream? |
CanRead | Can the stream be read? |
CanWrite | Can the stream be written to? |
Length | Length of the stream. |
Position | Current cursor position. |
Seek | Seek to a position. |
Read | Read bytes from the stream. |
Write | Write bytes to the stream. |
Flush | Flush any buffered data to the underlying device. |
Close | Close the stream and release any resources (such as sockets and file handles). ... |
Get .NET Programming: A Practical Guide Using C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.