StorageStreamTransaction class
Represents a write transaction for a random-access stream.
Syntax
Attributes
- MarshalingBehaviorAttribute(Agile)
- VersionAttribute(NTDDI_WIN8)
Members
The StorageStreamTransaction class has these types of members:
Methods
The StorageStreamTransaction class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| Close [C++, JavaScript] | Releases system resources that are exposed by the stream, indicating that the data request is complete. |
| CommitAsync | Save the stream to the underlying file. |
| Dispose [C#, VB] | Performs tasks associated with freeing, releasing, or resetting unmanaged resources. |
Properties
The StorageStreamTransaction class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets the random-access stream used in the transaction. |
Examples
The File Access sample shows you how to use a StorageStreamTransaction object to perform a transacted write operation on a file.
try { if (file != null) { using (StorageStreamTransaction transaction = await file.OpenTransactedWriteAsync()) { using (DataWriter dataWriter = new DataWriter(transaction.Stream)) { dataWriter.WriteString("Swift as a shadow"); transaction.Stream.Size = await dataWriter.StoreAsync(); // reset stream size to override the file await transaction.CommitAsync(); } } } } // Use catch blocks to handle errors catch (FileNotFoundException) { // For example, handle a file not found error }
In the example, file is a local variable that contains a storageFile that represents the file to write.
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 5/16/2013