Udostępnij za pośrednictwem


DataWriter Class

Definition

Writes data to an output stream.

public ref class DataWriter sealed : IClosable, IDataWriter
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Storage.Streams.IDataWriterFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DataWriter final : IClosable, IDataWriter
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(Windows.Storage.Streams.IDataWriterFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class DataWriter final : IClosable, IDataWriter
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Storage.Streams.IDataWriterFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DataWriter : System.IDisposable, IDataWriter
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Storage.Streams.IDataWriterFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class DataWriter : System.IDisposable, IDataWriter
function DataWriter(outputStream)
Public NotInheritable Class DataWriter
Implements IDataWriter, IDisposable
Inheritance
Object Platform::Object IInspectable DataWriter
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

See the code example in the DataReader topic.

Remarks

Instances of DataWriter objects do not support concurrent writes. If an application concurrently writes or detaches a stream from a DataWriter instance that is being written to the call to the object will fail with the error HRESULT_FROM_WIN32(ERROR_INVALID_OPERATION).

Constructors

DataWriter()

Creates and initializes a new instance of the data writer.

DataWriter(IOutputStream)

Creates and initializes a new instance of the data writer to an output stream.

Properties

ByteOrder

Gets or sets the byte order of the data in the output stream.

UnicodeEncoding

Gets or sets the Unicode character encoding for the output stream.

UnstoredBufferLength

Gets the size of the buffer that has not been used.

Methods

Close()

Closes the current stream and releases system resources.

DetachBuffer()

Detaches the buffer that is associated with the data writer.

DetachStream()

Detaches the stream that is associated with the data writer.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

FlushAsync()

Flushes data asynchronously.

MeasureString(String)

Gets the size of a string.

StoreAsync()

Commits data in the buffer to the output stream. This method should only be called when the DataWriter is writing into a stream; it will fail when the underlying store is a buffer.

WriteBoolean(Boolean)

Writes a Boolean value to the output stream.

WriteBuffer(IBuffer, UInt32, UInt32)

Writes the specified bytes from a buffer to the output stream.

WriteBuffer(IBuffer)

Writes the contents of the specified buffer to the output stream.

WriteByte(Byte)

Writes a byte value to the output stream.

WriteBytes(Byte[])

Writes an array of byte values to the output stream.

WriteDateTime(DateTime)

Writes a date and time value to the output stream.

WriteDouble(Double)

Writes a floating-point value to the output stream.

WriteGuid(Guid)

Writes a GUID value to the output stream.

WriteInt16(Int16)

Writes a 16-bit integer value to the output stream.

WriteInt32(Int32)

Writes a 32-bit integer value to the output stream.

WriteInt64(Int64)

Writes a 64-bit integer value to the output stream.

WriteSingle(Single)

Writes a floating-point value to the output stream.

WriteString(String)

Writes a string value to the output stream.

WriteTimeSpan(TimeSpan)

Writes a time-interval value to the output stream.

WriteUInt16(UInt16)

Writes a 16-bit unsigned integer value to the output stream.

WriteUInt32(UInt32)

Writes a 32-bit unsigned integer value to the output stream.

WriteUInt64(UInt64)

Writes a 64-bit unsigned integer value to the output stream.

Applies to

See also