Draft for Information Only
Content
Device I/O TextReader Class Constructors Fields Methods Remarks Applies to See also TextWriter Class Constructors Fields Properties Methods Remarks Applies to See also Source/Reference
Device I/O
The main components used in .NET framework to access the device i/o are Stream ,
BufferedStream , FileStream , MemoryStream , StreamReader , StreamWriter ,
StringReader , StringWriter , TextReader , TextWriter , BinaryReader , and
BinaryWriter .
TextReader Class
Represents a reader that can read a sequential series of characters.
Namespace System.IO
Assemblies System.IO.dll, mscorlib.dll, netstandard.dll, System.Runtime.Extensions.dll
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class TextReader : MarshalByRefObject, IDisposable
Inheritance: Object -> ->MarshalByRefObject ->TextReader
Derived: StreamReader , StringReader
Attributes: ComVisibleAttribute , SerializableAttribute
Implements: IDisposable
Constructors
Fields
Null
Provides a TextReader with no data to read from.
Methods
Close()
Closes the TextReader and releases any system resources associated with the TextReader.
CreateObjRef(Type)
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject )
Dispose()
Releases all resources used by the TextReader object.
Dispose(Boolean)
Releases the unmanaged resources used by the TextReader and optionally releases the managed resources.
Equals(Object)
Determines whether the specified object is equal to the current object.
(Inherited from Object )
GetHashCode()
Serves as the default hash function.
(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()
Reads the next character without changing the state of the reader or the character source. Returns the next available character without actually reading it from the reader.
Read()
Reads the next character from the text reader and advances the character position by one character.
Read(Char[], Int32, Int32)
Reads a specified maximum number of characters from the current reader and writes the data to a buffer, beginning at the specified index.
ReadAsync(Char[], Int32, Int32)
Reads a specified maximum number of characters from the current text reader asynchronously and writes the data to a buffer, beginning at the specified index.
ReadBlock(Char[], Int32, Int32)
Reads a specified maximum number of characters from the current text reader and writes the data to a buffer, beginning at the specified index.
ReadBlockAsync(Char[], Int32, Int32)
Reads a specified maximum number of characters from the current text reader asynchronously and writes the data to a buffer, beginning at the specified index.
ReadLine()
Reads a line of characters from the text reader and returns the data as a string.
ReadLineAsync()
Reads a line of characters asynchronously and returns the data as a string.
ReadToEnd()
Reads all characters from the current position to the end of the text reader and returns them as one string.
ReadToEndAsync()
Reads all characters from the current position to the end of the text reader asynchronously and returns them as one string.
Synchronized(TextReader)
Creates a thread-safe wrapper around the specified TextReader.
ToString()
Returns a string that represents the current object.
(Inherited from Object )
Remarks
TextReader is the abstract base class of StreamReader and StringReader , which read characters from streams and strings, respectively. Use these derived classes to open a text file for reading a specified range of characters, or to create a reader based on an existing stream.
Important
This type implements the IDisposable interface. When you have finished using any type that derives from this type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see Dispose and the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.
Notes to Inheritors
A derived class must minimally implement the Peek() and Read() methods to make a useful instance of TextReader .
Applies to
.NET Framework: 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1
See also
TextWriter Class
Represents a writer that can write a sequential series of characters. This class is abstract.
Namespace System.IO
Assemblies System.IO.dll, mscorlib.dll, netstandard.dll, System.Runtime.Extensions.dll
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class TextWriter : MarshalByRefObject, IDisposable
Inheritance: Object ->MarshalByRefObject ->TextWriter
Derived: IndentedTextWriter , StreamWriter , StringWriter , HttpWriter , HtmlTextWriter
Attributes
Implements: IDisposable
Constructors
Fields
CoreNewLine
Stores the newline characters used for this TextWriter.
Null
Provides a TextWriter with no backing store that can be written to, but not read from.
Properties
Encoding
When overridden in a derived class, returns the character encoding in which the output is written.
FormatProvider
Gets an object that controls formatting.
NewLine
Gets or sets the line terminator string used by the current TextWriter.
Methods
Close()
Closes the current writer and releases any system resources associated with the writer.
CreateObjRef(Type)
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject )
Dispose()
Releases all resources used by the TextWriter object.
Dispose(Boolean)
Releases the unmanaged resources used by the TextWriter and optionally releases the managed resources.
Equals(Object)
Determines whether the specified object is equal to the current object.
(Inherited from Object )
Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
FlushAsync()
Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
GetHashCode()
Serves as the default hash function.
(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 )
Synchronized(TextWriter)
Creates a thread-safe wrapper around the specified TextWriter.
ToString()
Returns a string that represents the current object.
(Inherited from Object )
Write(Boolean)
Writes the text representation of a Boolean value to the text stream.
Write(Char)
Writes a character to the text stream.
Write(Char[])
Writes a character array to the text stream.
Write(Char[], Int32, Int32)
Writes a subarray of characters to the text stream.
Write(Decimal)
Writes the text representation of a decimal value to the text stream.
Write(Double)
Writes the text representation of an 8-byte floating-point value to the text stream.
Write(Int32)
Writes the text representation of a 4-byte signed integer to the text stream.
Write(Int64)
Writes the text representation of an 8-byte signed integer to the text stream.
Write(Object)
Writes the text representation of an object to the text stream by calling the ToString method on that object.
Write(Single)
Writes the text representation of a 4-byte floating-point value to the text stream.
Write(String)
Writes a string to the text stream.
Write(String, Object)
Writes a formatted string to the text stream, using the same semantics as the Format(String, Object) method.
Write(String, Object, Object)
Writes a formatted string to the text stream using the same semantics as the Format(String, Object, Object) method.
Write(String, Object, Object, Object)
Writes a formatted string to the text stream, using the same semantics as the Format(String, Object, Object, Object) method.
Write(String, Object[])
Writes a formatted string to the text stream, using the same semantics as the Format(String, Object[]) method.
Write(UInt32)
Writes the text representation of a 4-byte unsigned integer to the text stream.
Write(UInt64)
Writes the text representation of an 8-byte unsigned integer to the text stream.
WriteAsync(Char)
Writes a character to the text stream asynchronously.
WriteAsync(Char[])
Writes a character array to the text stream asynchronously.
WriteAsync(Char[], Int32, Int32)
Writes a subarray of characters to the text stream asynchronously.
WriteAsync(String)
Writes a string to the text stream asynchronously.
WriteLine()
Writes a line terminator to the text stream.
WriteLine(Boolean)
Writes the text representation of a Boolean value to the text stream, followed by a line terminator.
WriteLine(Char)
Writes a character to the text stream, followed by a line terminator.
WriteLine(Char[])
Writes an array of characters to the text stream, followed by a line terminator.
WriteLine(Char[], Int32, Int32)
Writes a subarray of characters to the text stream, followed by a line terminator.
WriteLine(Decimal)
Writes the text representation of a decimal value to the text stream, followed by a line terminator.
WriteLine(Double)
Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator.
WriteLine(Int32)
Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator.
WriteLine(Int64)
Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator.
WriteLine(Object)
Writes the text representation of an object to the text stream, by calling the ToString method on that object, followed by a line terminator.
WriteLine(Single)
Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator.
WriteLine(String)
Writes a string to the text stream, followed by a line terminator.
WriteLine(String, Object)
Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object) method.
WriteLine(String, Object, Object)
Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object, Object) method.
WriteLine(String, Object, Object, Object)
Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object) .
WriteLine(String, Object[])
Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object) .
WriteLine(UInt32)
Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator.
WriteLine(UInt64)
Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator.
WriteLineAsync()
Asynchronously writes a line terminator to the text stream.
WriteLineAsync(Char)
Asynchronously writes a character to the text stream, followed by a line terminator.
WriteLineAsync(Char[])
Asynchronously writes an array of characters to the text stream, followed by a line terminator.
WriteLineAsync(Char[], Int32, Int32)
Asynchronously writes a subarray of characters to the text stream, followed by a line terminator.
WriteLineAsync(String)
Asynchronously writes a string to the text stream, followed by a line terminator.
Remarks
TextWriter is the abstract base class of StreamWriter and StringWriter , which write characters to streams and strings, respectively. Create an instance of TextWriter to write an object to a string, write strings to a file, or to serialize XML. You can also use an instance of
TextWriter to write text to a custom backing store using the same APIs you would use for a string or a stream, or to add support for text formatting.
All the Write methods of TextWriter having primitive data types as parameters write out the values as strings.
By default, a TextWriter is not thread safe. See TextWriter.Synchronized for a thread-safe wrapper.
Important
This type implements the IDisposable interface. When you have finished using any type that derives from this type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see Dispose and the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.
For a list of common I/O tasks, see Common I/O Tasks .
Notes to Inheritors
A derived class must minimally implement the Write(Char) method to make a useful instance of TextWriter .
Applies to
.NET Framework: 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1
See also
Source/Reference
©sideway
ID: 200700014 Last Updated: 7/14/2020 Revision: 0 Ref:
References
Active Server Pages, , http://msdn.microsoft.com/en-us/library/aa286483.aspx
ASP Overview, , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
ASP Best Practices, , http://technet.microsoft.com/en-us/library/cc939157.aspx
ASP Built-in Objects, , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
Response Object, , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
Request Object, , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
Server Object (IIS), , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
Application Object (IIS), , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
Session Object (IIS), , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
ASPError Object, , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
ObjectContext Object (IIS), , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
Debugging Global.asa Files, , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
How to: Debug Global.asa files, , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
Calling COM Components from ASP Pages, , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
IIS ASP Scripting Reference, , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
ASP Keywords, , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
Creating Simple ASP Pages, , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
Including Files in ASP Applications, , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
ASP Overview, , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
FileSystemObject Object, , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, , ADO Object Model
ADO Fundamentals, , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx