在C#中,常用的文件操作包含文件的移动,复制,文件的读写,其中文件的读写分为文本文件以及二进制文件。
文本文件与二进制文件有各自的优缺点,文本文件按照字符的ASCII码进行存储,所以你可以直接用记事本打开文本文件,可以看到文件的内容,但是文件的所有的内容在内存中的表示和在记事本中的表示是不一样的,所以读入内存会存在转码的时间消耗,如果你想让文件直观的话,可以采用文本文件。
二进制文件则是直接存储你需要存储内容的在内存中的直接表示,在读取的时候比较快捷,而且二进制文件的大小要比文本文件小很多。
常用的文件操作类是File,File类是一个静态类,所有的成员函数都为静态函数,所以File类的效率比其他的例如FileInfo类的效率要高。一般情况下,File和FileInfo可以实现的功能大同小异。可以根据自己的需要选择不同的类。
File支持文件的基本操作,包括提供了创建、复制、删除、移动、打开以及获取文件的其他的相关属性的一些方法。
同时,为了更好的支持File文件的操作,C#中定义了一个文件流FileStream,可以将文件加载到文件流FileStream中进行更加方便的操作。
为了对FileStream进行操作,C#定义了两组最常用的操作FileStream的类,一组是StreamReader, StreamWriter, 另外一组是BinaryReader, BinaryWriter,。这两组类分别提供了进行文本文件读写以及二进制文件的读取操作。
文件的操作还有一些其他的类,但是对于常用的一些基本的文件操作,有File, FileStream, StreamReader, StreamWriter,BinaryReader, BinaryWriter,这几个类就足够了。
File类的定义,如下所示:
File Members |
Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
The File type exposes the following members.
Name | Description | |
---|---|---|
AppendAllLines(String, IEnumerable<String>) | Appends lines to a file, and then closes the file. | |
AppendAllLines(String, IEnumerable<String>, Encoding) | Appends lines to a file by using a specified encoding, and then closes the file. | |
AppendAllText(String, String) | Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file. | |
AppendAllText(String, String, Encoding) | Appends the specified string to the file, creating the file if it does not already exist. | |
AppendText | Creates a StreamWriter that appends UTF-8 encoded text to an existing file. | |
Copy(String, String) | Copies an existing file to a new file. Overwriting a file of the same name is not allowed. | |
Copy(String, String, Boolean) | Copies an existing file to a new file. Overwriting a file of the same name is allowed. | |
Create(String) | Creates or overwrites a file in the specified path. | |
Create(String, Int32) | Creates or overwrites the specified file. | |
Create(String, Int32, FileOptions) | Creates or overwrites the specified file, specifying a buffer size and a FileOptions value that describes how to create or overwrite the file. | |
Create(String, Int32, FileOptions, FileSecurity) | Creates or overwrites the specified file with the specified buffer size, file options, and file security. | |
CreateText | Creates or opens a file for writing UTF-8 encoded text. | |
Decrypt | Decrypts a file that was encrypted by the current account using the Encrypt method. | |
Delete | Deletes the specified file. An exception is not thrown if the specified file does not exist. | |
Encrypt | Encrypts a file so that only the account used to encrypt the file can decrypt it. | |
Exists | Determines whether the specified file exists. | |
GetAccessControl(String) | Gets a FileSecurity object that encapsulates the access control list (ACL) entries for a specified file. | |
GetAccessControl(String, AccessControlSections) | Gets a FileSecurity object that encapsulates the specified type of access control list (ACL) entries for a particular file. | |
GetAttributes | Gets the FileAttributes of the file on the path. | |
GetCreationTime | Returns the creation date and time of the specified file or directory. | |
GetCreationTimeUtc | Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory. | |
GetLastAccessTime | Returns the date and time the specified file or directory was last accessed. | |
GetLastAccessTimeUtc | Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed. | |
GetLastWriteTime | Returns the date and time the specified file or directory was last written to. | |
GetLastWriteTimeUtc | Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to. | |
Move | Moves a specified file to a new location, providing the option to specify a new file name. | |
Open(String, FileMode) | Opens a FileStream on the specified path with read/write access. | |
Open(String, FileMode, FileAccess) | Opens a FileStream on the specified path, with the specified mode and access. | |
Open(String, FileMode, FileAccess, FileShare) | Opens a FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. | |
OpenRead | Opens an existing file for reading. | |
OpenText | Opens an existing UTF-8 encoded text file for reading. | |
OpenWrite | Opens an existing file or creates a new file for writing. | |
ReadAllBytes | Opens a binary file, reads the contents of the file into a byte array, and then closes the file. | |
ReadAllLines(String) | Opens a text file, reads all lines of the file, and then closes the file. | |
ReadAllLines(String, Encoding) | Opens a file, reads all lines of the file with the specified encoding, and then closes the file. | |
ReadAllText(String) | Opens a text file, reads all lines of the file, and then closes the file. | |
ReadAllText(String, Encoding) | Opens a file, reads all lines of the file with the specified encoding, and then closes the file. | |
ReadLines(String) | Reads the lines of a file. | |
ReadLines(String, Encoding) | Read the lines of a file that has a specified encoding. | |
Replace(String, String, String) | Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file. | |
Replace(String, String, String, Boolean) | Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors. | |
SetAccessControl | Applies access control list (ACL) entries described by a FileSecurity object to the specified file. | |
SetAttributes | Sets the specified FileAttributes of the file on the specified path. | |
SetCreationTime | Sets the date and time the file was created. | |
SetCreationTimeUtc | Sets the date and time, in coordinated universal time (UTC), that the file was created. | |
SetLastAccessTime | Sets the date and time the specified file was last accessed. | |
SetLastAccessTimeUtc | Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. | |
SetLastWriteTime | Sets the date and time that the specified file was last written to. | |
SetLastWriteTimeUtc | Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. | |
WriteAllBytes | Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten. | |
WriteAllLines(String, IEnumerable<String>) | Creates a new file, writes a collection of strings to the file, and then closes the file. | |
WriteAllLines(String,String[]) | Creates a new file, write the specified string array to the file, and then closes the file. | |
WriteAllLines(String, IEnumerable<String>, Encoding) | Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. | |
WriteAllLines(String,String[], Encoding) | Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file. | |
WriteAllText(String, String) | Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten. | |
WriteAllText(String, String, Encoding) | Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. |
然后在看看我们的FileStream类的成员:
FileStream Members |
Exposes a Stream around a file, supporting both synchronous and asynchronous read and write operations.
The FileStream type exposes the following members.
Name | Description | |
---|---|---|
FileStream(IntPtr, FileAccess) | Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission. | |
FileStream(SafeFileHandle, FileAccess) | Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission. | |
FileStream(String, FileMode) | Initializes a new instance of the FileStream class with the specified path and creation mode. | |
FileStream(IntPtr, FileAccess, Boolean) | Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission and FileStream instance ownership. | |
FileStream(SafeFileHandle, FileAccess, Int32) | Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, and buffer size. | |
FileStream(String, FileMode, FileAccess) | Initializes a new instance of the FileStream class with the specified path, creation mode, and read/write permission. | |
FileStream(IntPtr, FileAccess, Boolean, Int32) | Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, FileStream instance ownership, and buffer size. | |
FileStream(SafeFileHandle, FileAccess, Int32, Boolean) | Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, buffer size, and synchronous or asynchronous state. | |
FileStream(String, FileMode, FileAccess, FileShare) | Initializes a new instance of the FileStream class with the specified path, creation mode, read/write permission, and sharing permission. | |
FileStream(IntPtr, FileAccess, Boolean, Int32, Boolean) | Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, FileStream instance ownership, buffer size, and synchronous or asynchronous state. | |
FileStream(String, FileMode, FileAccess, FileShare, Int32) | Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, and buffer size. | |
FileStream(String, FileMode, FileAccess, FileShare, Int32, Boolean) | Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, buffer size, and synchronous or asynchronous state. | |
FileStream(String, FileMode, FileAccess, FileShare, Int32, FileOptions) | Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, the access other FileStreams can have to the same file, the buffer size, and additional file options. | |
FileStream(String, FileMode, FileSystemRights, FileShare, Int32, FileOptions) | Initializes a new instance of the FileStream class with the specified path, creation mode, access rights and sharing permission, the buffer size, and additional file options. | |
FileStream(String, FileMode, FileSystemRights, FileShare, Int32, FileOptions, FileSecurity) | Initializes a new instance of the FileStream class with the specified path, creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security. |
Name | Description | |
---|---|---|
BeginRead | Begins an asynchronous read. (Overrides Stream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) .) In XNA Framework 3.0, this member is inherited from Stream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) . | |
BeginRead | Begins an asynchronous read operation. (Inherited from Stream.) | |
BeginWrite | Begins an asynchronous write. (Overrides Stream.BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) .) In XNA Framework 3.0, this member is inherited from Stream.BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) . | |
BeginWrite | Begins an asynchronous write operation. (Inherited from Stream.) | |
Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from Stream.) | |
CopyTo(Stream) | Reads all the bytes from the current stream and writes them to the destination stream. (Inherited from Stream.) | |
CopyTo(Stream, Int32) | Reads all the bytes from the current stream and writes them to a destination stream, using a specified buffer size. (Inherited from Stream.) | |
CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
CreateWaitHandle | Obsolete. Allocates a WaitHandle object. (Inherited from Stream.) | |
Dispose() | Infrastructure. Releases all resources used by the Stream. (Inherited from Stream.) | |
Dispose(Boolean) | Releases the unmanaged resources used by the FileStream and optionally releases the managed resources. (Overrides Stream.Dispose(Boolean) .) | |
EndRead | Waits for the pending asynchronous read to complete. (Overrides Stream.EndRead(IAsyncResult) .) In XNA Framework 3.0, this member is inherited from Stream.EndRead(IAsyncResult). | |
EndRead | Waits for the pending asynchronous read to complete. (Inherited from Stream.) | |
EndWrite | Ends an asynchronous write, blocking until the I/O operation has completed. (Overrides Stream.EndWrite(IAsyncResult) .) In XNA Framework 3.0, this member is inherited from Stream.EndWrite(IAsyncResult). | |
EndWrite | Ends an asynchronous write operation. (Inherited from Stream.) | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the FileStream. (Overrides Object.Finalize().) | |
Flush() | Clears buffers for this stream and causes any buffered data to be written to the file. (Overrides Stream.Flush().) | |
Flush(Boolean) | Clears buffers for this stream and causes any buffered data to be written to the file, and also clears all intermediate file buffers. | |
GetAccessControl | Gets a FileSecurity object that encapsulates the access control list (ACL) entries for the file described by the current FileStream object. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
Lock | Prevents other processes from reading from or writing to the FileStream. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | |
ObjectInvariant | Infrastructure. Provides support for a Contract. (Inherited from Stream.) | |
Read | Reads a block of bytes from the stream and writes the data in a given buffer. (Overrides Stream.Read(Byte[], Int32, Int32) .) | |
ReadByte | Reads a byte from the file and advances the read position one byte. (Overrides Stream.ReadByte().) | |
Seek | Sets the current position of this stream to the given value. (Overrides Stream.Seek(Int64, SeekOrigin) .) | |
SetAccessControl | Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileStream object. | |
SetLength | Sets the length of this stream to the given value. (Overrides Stream.SetLength(Int64) .) | |
ToString | Returns a String that represents the current Object. (Inherited from Object.) | |
Unlock | Allows access by other processes to all or part of a file that was previously locked. | |
Write | Writes a block of bytes to this stream using data from a buffer. (Overrides Stream.Write(Byte[], Int32, Int32) .) | |
WriteByte | Writes a byte to the current position in the file stream. (Overrides Stream.WriteByte(Byte) .) |
Name | Description | |
---|---|---|
CanRead | Gets a value indicating whether the current stream supports reading. (Overrides Stream.CanRead .) | |
CanSeek | Gets a value indicating whether the current stream supports seeking. (Overrides Stream.CanSeek .) | |
CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from Stream.) | |
CanWrite | Gets a value indicating whether the current stream supports writing. (Overrides Stream.CanWrite .) | |
Handle | Obsolete. Gets the operating system file handle for the file that the current FileStream object encapsulates. | |
IsAsync | Gets a value indicating whether the FileStream was opened asynchronously or synchronously. | |
Length | Gets the length in bytes of the stream. (Overrides Stream.Length .) | |
Name | Gets the name of the FileStream that was passed to the constructor. | |
Position | Gets or sets the current position of this stream. (Overrides Stream.Position .) | |
ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from Stream.) | |
SafeFileHandle | Gets a SafeFileHandle object that represents the operating system file handle for the file that the current FileStream object encapsulates. | |
WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from Stream.) |
可以看到都是对字节流的操作,这种对于字节流的操作,对于大部分来说还是比较困难的,所以c#又帮助我们封装了对FileStream的操作,那就是StreamReader, StreamWriter, BinaryReader, BinaryWriter.
下面分别看看这两组类怎么使用:
StreamReader, StreamWriter
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace FileOperater
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
if (File.Exists("record.txt"))
{
FileStream fs = new FileStream("record.txt", FileMode.Open);
StreamReader sr = new StreamReader(fs);
while (!sr.EndOfStream)
{
string msg = sr.ReadLine();
this.richTextBox1.Text += msg + Environment.NewLine;
}
sr.Close();
fs.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("record.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
string text = richTextBox1.Text;
sw.WriteLine(text);
// 添加一些其他的信息
sw.WriteLine("i love C# programming!");
sw.WriteLine("what's ur favourate programming language?");
sw.Flush();
sw.Close();
fs.Close();
}
}
}
这个时候打开文本文件,可以看到你输入的内容和添加的内容。
BinaryWriter, BinaryReader.
这个时候我们添加三个TextBox ,可以将TextBox中输入的数字转换为对应的整数,然后将整数以及在richTextBox中的字符串都以二进制的方式写入文件。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace FileOperater
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
if (File.Exists("binary"))
{
FileStream fs = new FileStream("binary", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
int a1 = br.ReadInt32();
int a2 = br.ReadInt32();
int a3 = br.ReadInt32();
string msg = br.ReadString();
this.textBox1.Text = a1.ToString();
textBox2.Text = a2.ToString();
textBox3.Text = a3.ToString();
richTextBox1.Text = msg;
br.Close();
fs.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("record.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
string text = richTextBox1.Text;
sw.WriteLine(text);
// 添加一些其他的信息
sw.WriteLine("i love C# programming!");
sw.WriteLine("what's ur favourate programming language?");
sw.Flush();
sw.Close();
fs.Close();
}
private void button2_Click(object sender, EventArgs e)
{
int a1 = int.Parse(textBox1.Text.Trim());
int a2 = int.Parse(textBox2.Text.Trim());
int a3 = int.Parse(textBox3.Text.Trim());
string msg = richTextBox1.Text.Trim();
FileStream fs = new FileStream("binary", FileMode.OpenOrCreate);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(a1);
bw.Write(a2);
bw.Write(a3);
bw.Write(msg);
bw.Flush();
bw.Close();
fs.Close();
}
}
}
操作二进制文件,一定要按照写入文件的顺序来读文件,否则肯定会出现不可预知的错误。
StreamReader Members |
Implements a TextReader that reads characters from a byte stream in a particular encoding.
The StreamReader type exposes the following members.
Name | Description | |
---|---|---|
StreamReader(Stream) | Initializes a new instance of the StreamReader class for the specified stream. | |
StreamReader(String) | Initializes a new instance of the StreamReader class for the specified file name. | |
StreamReader(Stream, Boolean) | Initializes a new instance of the StreamReader class for the specified stream, with the specified byte order mark detection option. | |
StreamReader(Stream, Encoding) | Initializes a new instance of the StreamReader class for the specified stream, with the specified character encoding. | |
StreamReader(String, Boolean) | Initializes a new instance of the StreamReader class for the specified file name, with the specified byte order mark detection option. | |
StreamReader(String, Encoding) | Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding. | |
StreamReader(Stream, Encoding, Boolean) | Initializes a new instance of the StreamReader class for the specified stream, with the specified character encoding and byte order mark detection option. | |
StreamReader(String, Encoding, Boolean) | Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding and byte order mark detection option. | |
StreamReader(Stream, Encoding, Boolean, Int32) | Initializes a new instance of the StreamReader class for the specified stream, with the specified character encoding, byte order mark detection option, and buffer size. | |
StreamReader(String, Encoding, Boolean, Int32) | Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding, byte order mark detection option, and buffer size. |
Name | Description | |
---|---|---|
Close | Closes the StreamReader object and the underlying stream, and releases any system resources associated with the reader. (Overrides TextReader.Close().) | |
CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
DiscardBufferedData | Allows a StreamReader object to discard its current data. | |
Dispose() | Releases all resources used by the TextReader object. (Inherited from TextReader.) | |
Dispose(Boolean) | Closes the underlying stream, releases the unmanaged resources used by the StreamReader, and optionally releases the managed resources. (Overrides TextReader.Dispose(Boolean) .) | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | |
Peek | Returns the next available character but does not consume it. (Overrides TextReader.Peek().) | |
Read() | Reads the next character from the input stream and advances the character position by one character. (Overrides TextReader.Read().) | |
Read(Char[], Int32, Int32) | Reads a maximum of count characters from the current stream into buffer, beginning at index. (Overrides TextReader.Read(Char[], Int32, Int32) .) | |
ReadBlock | Reads a maximum of count characters from the current stream, and writes the data to buffer, beginning at index. (Inherited from TextReader.) | |
ReadLine | Reads a line of characters from the current stream and returns the data as a string. (Overrides TextReader.ReadLine().) | |
ReadToEnd | Reads the stream from the current position to the end of the stream. (Overrides TextReader.ReadToEnd().) | |
ToString | Returns a String that represents the current Object. (Inherited from Object.) |
BinaryReader Members |
Reads primitive data types as binary values in a specific encoding.
The BinaryReader type exposes the following members.
Name | Description | |
---|---|---|
BinaryReader(Stream) | Initializes a new instance of the BinaryReader class based on the supplied stream and using UTF8Encoding. | |
BinaryReader(Stream, Encoding) | Initializes a new instance of the BinaryReader class based on the supplied stream and a specific character encoding. |
Name | Description | |
---|---|---|
Close | Closes the current reader and the underlying stream. | |
Dispose() | Releases all resources used by the current instance of the BinaryReader class. | |
Dispose(Boolean) | Releases the unmanaged resources used by the BinaryReader class and optionally releases the managed resources. | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FillBuffer | Fills the internal buffer with the specified number of bytes read from the stream. | |
Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
PeekChar | Returns the next available character and does not advance the byte or character position. | |
Read() | Reads characters from the underlying stream and advances the current position of the stream in accordance with the Encoding used and the specific character being read from the stream. | |
Read(Byte[], Int32, Int32) | Reads the specified number of bytes from the stream, starting from a specified point in the byte array. | |
Read(Char[], Int32, Int32) | Reads the specified number of characters from the stream, starting from a specified point in the character array. | |
Read7BitEncodedInt | Reads in a 32-bit integer in compressed format. | |
ReadBoolean | Reads a Boolean value from the current stream and advances the current position of the stream by one byte. | |
ReadByte | Reads the next byte from the current stream and advances the current position of the stream by one byte. | |
ReadBytes | Reads the specified number of bytes from the current stream into a byte array and advances the current position by that number of bytes. | |
ReadChar | Reads the next character from the current stream and advances the current position of the stream in accordance with the Encoding used and the specific character being read from the stream. | |
ReadChars | Reads the specified number of characters from the current stream, returns the data in a character array, and advances the current position in accordance with the Encoding used and the specific character being read from the stream. | |
ReadDecimal | Reads a decimal value from the current stream and advances the current position of the stream by sixteen bytes. | |
ReadDouble | Reads an 8-byte floating point value from the current stream and advances the current position of the stream by eight bytes. | |
ReadInt16 | Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes. | |
ReadInt32 | Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes. | |
ReadInt64 | Reads an 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes. | |
ReadSByte | Reads a signed byte from this stream and advances the current position of the stream by one byte. | |
ReadSingle | Reads a 4-byte floating point value from the current stream and advances the current position of the stream by four bytes. | |
ReadString | Reads a string from the current stream. The string is prefixed with the length, encoded as an integer seven bits at a time. | |
ReadUInt16 | Reads a 2-byte unsigned integer from the current stream using little-endian encoding and advances the position of the stream by two bytes. | |
ReadUInt32 | Reads a 4-byte unsigned integer from the current stream and advances the position of the stream by four bytes. | |
ReadUInt64 | Reads an 8-byte unsigned integer from the current stream and advances the position of the stream by eight bytes. | |
ToString | Returns a String that represents the current Object. (Inherited from Object.) |