Class DataWriter
Writes data to an output stream.
Inherited Members
Namespace: Windows.Storage.Streams
Assembly: Windows.Storage.Streams.dll
Syntax
public sealed class DataWriter : MarshalByRefObject, IDisposable, IDataWriter
Constructors
DataWriter()
Creates and initializes a new instance of the data writer.
Declaration
public DataWriter()
DataWriter(IOutputStream)
Creates and initializes a new instance of the data writer to an output stream.
Declaration
public DataWriter(IOutputStream outputStream)
Parameters
Type | Name | Description |
---|---|---|
IOutputStream | outputStream | The new output stream instance. |
Properties
ByteOrder
Gets or sets the byte order of the data in the output stream.
Declaration
public ByteOrder ByteOrder { get; }
Property Value
Type | Description |
---|---|
ByteOrder | One of the enumeration values. |
Remarks
nanoFramework doesn't this feature. ByteOrder is always LittleEndian.
UnicodeEncoding
Gets or sets the Unicode character encoding for the output stream.
Declaration
public UnicodeEncoding UnicodeEncoding { get; }
Property Value
Type | Description |
---|---|
UnicodeEncoding | One of the enumeration values. |
Remarks
nanoFramework doesn't this feature. UnicodeEncoding is always Utf8.
UnstoredBufferLength
Gets the size of the buffer that has not been used.
Declaration
public uint UnstoredBufferLength { get; }
Property Value
Type | Description |
---|---|
uint | The available buffer length, in bytes. |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Flush()
Flushes data.
Declaration
public bool Flush()
Returns
Type | Description |
---|---|
bool | The stream flush operation. |
Remarks
The Flush method ensures that the data has reached the target storage medium that the stream represents. For example, to improve application responsiveness and throughput, a file stream might respond to a write operation by copying the buffer into another temporary storage medium and returning immediately, while the target device begins writing the data concurrently. The Flush method doesn't complete until all data specified in previous write calls has reached the target storage medium. If the data can't be written, or an error occurred during a write operation, the method returns false. The Flush method may produce latencies and does not always guarantee durable and coherent storage of data.It's generally recommended to avoid this method if possible. This method is specific to nanoFramework. The equivalent method in the UWP API is: FlushAsync.
MeasureString(string)
Gets the size of a string.
Declaration
public uint MeasureString(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string. |
Returns
Type | Description |
---|---|
uint | The size of the string, in bytes. |
Store()
Commits data in the buffer to a backing store.
Declaration
public uint Store()
Returns
Type | Description |
---|---|
uint | The store data operation. |
Remarks
This method is specific to nanoFramework. The equivalent method in the UWP API is: StoreAsync.
WriteBoolean(bool)
Writes a Boolean value to the output stream.
Declaration
public void WriteBoolean(bool value)
Parameters
Type | Name | Description |
---|---|---|
bool | value | The value to write. |
WriteBuffer(IBuffer, uint, uint)
Writes a range of bytes from a buffer to the output stream.
Declaration
public void WriteBuffer(IBuffer buffer, uint start, uint count)
Parameters
Type | Name | Description |
---|---|---|
IBuffer | buffer | The buffer. |
uint | start | The starting byte to be written. |
uint | count | The number of bytes to write. |
WriteBuffer(IBuffer)
Writes a number of bytes from a buffer to the output stream.
Declaration
public void WriteBuffer(IBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
IBuffer | buffer | The value to write. |
WriteByte(byte)
Writes a byte value to the output stream.
Declaration
public void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | The value to write. |
WriteBytes(byte[])
Writes an array of byte values to the output stream.
Declaration
public void WriteBytes(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
byte[] | value | The value to write. |
WriteDateTime(DateTime)
Writes a date and time value to the output stream.
Declaration
public void WriteDateTime(DateTime value)
Parameters
Type | Name | Description |
---|---|---|
DateTime | value | The value to write. |
WriteDouble(double)
Writes a floating-point value to the output stream.
Declaration
public void WriteDouble(double value)
Parameters
Type | Name | Description |
---|---|---|
double | value | The value to write. |
WriteGuid(Guid)
Writes a GUID value to the output stream.
Declaration
public void WriteGuid(Guid value)
Parameters
Type | Name | Description |
---|---|---|
Guid | value | The value to write. |
WriteInt16(short)
Writes a 16-bit integer value to the output stream.
Declaration
public void WriteInt16(short value)
Parameters
Type | Name | Description |
---|---|---|
short | value | The value to write. |
WriteInt32(int)
Writes a 32-bit integer value to the output stream.
Declaration
public void WriteInt32(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to write. |
WriteInt64(long)
Writes a 64-bit integer value to the output stream.
Declaration
public void WriteInt64(long value)
Parameters
Type | Name | Description |
---|---|---|
long | value | The value to write. |
WriteSingle(float)
Write a floating-point value to the output stream.
Declaration
public void WriteSingle(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The value to write. |
WriteString(string)
Writes a string value to the output stream.
Declaration
public uint WriteString(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value to write. |
Returns
Type | Description |
---|---|
uint | The length of the string. |
WriteTimeSpan(TimeSpan)
Writes a time interval value to the output stream.
Declaration
public void WriteTimeSpan(TimeSpan value)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | value | The value to write. |
WriteUInt16(ushort)
Writes a 16-bit unsigned integer value to the output stream.
Declaration
public void WriteUInt16(ushort value)
Parameters
Type | Name | Description |
---|---|---|
ushort | value | The value to write. |
WriteUInt32(uint)
Writes a 32-bit unsigned integer value to the output stream.
Declaration
public void WriteUInt32(uint value)
Parameters
Type | Name | Description |
---|---|---|
uint | value | The value to write. |
WriteUInt64(ulong)
Writes a 64-bit unsigned integer value to the output stream.
Declaration
public void WriteUInt64(ulong value)
Parameters
Type | Name | Description |
---|---|---|
ulong | value | The value to write. |