Represents a writer that can write a sequential series of characters. This class is abstract.
For a list of all members of this type, see TextWriter Members.
System.Object
System.MarshalByRefObject
System.IO.TextWriter
System.CodeDom.Compiler.IndentedTextWriter
System.IO.StreamWriter
System.IO.StringWriter
System.Web.HttpWriter
System.Web.UI.HtmlTextWriter
[Visual Basic] <Serializable> MustInherit Public Class TextWriter Inherits MarshalByRefObject Implements IDisposable [C#] [Serializable] public abstract class TextWriter : MarshalByRefObject, IDisposable [C++] [Serializable] public __gc __abstract class TextWriter : public MarshalByRefObject, IDisposable [JScript] public Serializable abstract class TextWriter extends MarshalByRefObject implements IDisposable
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
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 TextReader 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.
A derived class must minimally implement the
The following table lists examples of other typical or related I/O tasks.
| To do this... | See the example in this topic... |
|---|---|
| Create a text file. | |
| Write to a text file. | |
| Read from a text file. | |
| Append text to a file. | |
| Get the size of a file. | FileInfo.Length |
| Get the attributes of a file. | File.GetAttributes |
| Set the attributes of a file. | File.SetAttributes |
| Determine if a file exists. | File.Exists |
| Read from a binary file. | |
| Write to a binary file. |
Namespace: System.IO
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: Mscorlib (in Mscorlib.dll)
TextWriter Members | System.IO Namespace |