Share via


ProtectedFileStream.CreateAsync method

Creates a ProtectedFileStream from a UserPolicy object and a backing stream.

This method is used to create a protected file. The protected file is written to the specified backing stream. The policy used to protect the protected file is defined by the specified UserPolicy object. The resulting ProtectedFileStream can be used to write the actual content of the protected file (as a regular IRandomAccessStream).

[!Warning]
To avoid data loss and/or corruption, FlushAsync must be called if you modify the created stream or before object disposal.

[!Warning]
This method must be called on a UI thread. Calling it on a worker thread may result in an unexpected behavior.

Syntax

public:
static IAsyncOperation<ProtectedFileStream> CreateAsync(
  UserPolicy^ policy, 
  IRandomAccessStream^ inputStream, 
  String^ originalFileExtension
)

Parameters

policy

Type: UserPolicy

The UserPolicy object that defines the policy used to protect the created PFILE.

inputStream

Type: IRandomAccessStream

The stream from which the protected file is loaded.

originalFileExtension

Type: String

The original (i.e. unprotected) file extension.

Return value

Type: IAsyncOperation<ProtectedFileStream>

The asynchronous operation. Upon completion, IAsyncOperation.GetResults returns a ProtectedFileStream object that can be used to write content to the protected file.

Remarks

The Policy property of the new ProtectedFileStream object is populated from the protected file.

[!Warning]
To avoid data loss and/or corruption, FlushAsync must be called if you modify the created stream or before object disposal.

[!Warning]
This method must be called on a UI thread. Calling it on a worker thread may result in an unexpected behavior.

Requirements

Minimum supported client
None supported
Minimum supported server
None supported
Minimum supported phone
Windows Phone 8.1
Namespace
Microsoft::Protection
Metadata
Microsoft.RightsManagement.winmd

See also

ProtectedFileStream