PersonalStorage.CreateAsync

CreateAsync(string, FileFormatVersion, CancellationToken)

Asynchronously creates a new PST file.

public static Task<PersonalStorage> CreateAsync(string fileName, FileFormatVersion version, 
    CancellationToken token = default)
ParameterTypeDescription
fileNameStringThe path of the file to create. The file must not exist.
versionFileFormatVersionThe version of the PST. Only FileFormatVersion.Unicode is supported.
tokenCancellationTokenA token to cancel the operation.

Return Value

A task whose result is the new PST, open for writing.

Exceptions

exceptioncondition
NotImplementedExceptionversion is FileFormatVersion.ANSI.
ArgumentNullExceptionfileName is null or empty.
IOExceptionA file named fileName already exists.

Remarks

Only Unicode PST files can be created.

See Also


CreateAsync(Stream, FileFormatVersion, CancellationToken)

Asynchronously creates a new PST in a stream.

public static Task<PersonalStorage> CreateAsync(Stream stream, FileFormatVersion version, 
    CancellationToken token = default)
ParameterTypeDescription
streamStreamThe stream to write the PST to.
versionFileFormatVersionThe version of the PST. Only FileFormatVersion.Unicode is supported.
tokenCancellationTokenA token to cancel the operation.

Return Value

A task whose result is the new PST, open for writing.

Exceptions

exceptioncondition
NotImplementedExceptionversion is FileFormatVersion.ANSI.
ArgumentNullExceptionstream is null.

Remarks

Only Unicode PST files can be created. The stream is closed when the storage is disposed. Use the overload with leaveStreamOpen to keep it open.

See Also


CreateAsync(Stream, FileFormatVersion, bool, CancellationToken)

Asynchronously creates a new PST in a stream.

public static Task<PersonalStorage> CreateAsync(Stream stream, FileFormatVersion version, 
    bool leaveStreamOpen, CancellationToken token = default)
ParameterTypeDescription
streamStreamThe stream to write the PST to.
versionFileFormatVersionThe version of the PST. Only FileFormatVersion.Unicode is supported.
leaveStreamOpenBooleantrue to leave stream open when the storage is disposed.
tokenCancellationTokenA token to cancel the operation.

Return Value

A task whose result is the new PST, open for writing.

Exceptions

exceptioncondition
NotImplementedExceptionversion is FileFormatVersion.ANSI.
ArgumentNullExceptionstream is null.

Remarks

Only Unicode PST files can be created.

See Also