BinaryWriter::Write Method (String^)
Writes a length-prefixed string to this stream in the current encoding of the BinaryWriter, and advances the current position of the stream in accordance with the encoding used and the specific characters being written to the stream.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
-
Type:
System::String^
The value to write.
| Exception | Condition |
|---|---|
| IOException | An I/O error occurs. |
| ArgumentNullException | value is null. |
| ObjectDisposedException | The stream is closed. |
Length-prefixed means that this method first writes the length of the string, in bytes, when encoded with the BinaryWriter instance's current encoding to the stream. This value is written as an unsigned integer. This method then writes that many bytes to the stream.
For example, the string “A” has a length of 1, but when encoded with UTF-16; the length is 2 bytes, so the value written in the prefix is 2, and 3 bytes are written to the stream, including the prefix.
For a list of common I/O tasks, see Common I-O Tasks.
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1