-api-id | -api-type |
---|---|
M:Windows.Storage.IStorageFile2.OpenAsync(Windows.Storage.FileAccessMode,Windows.Storage.StorageOpenOptions) |
winrt method |
Opens a random-access stream over the file.
One of the enumeration values that specifies the type of access to allow.
A bitwise combination of the enumeration values that specify options for opening the stream.
When this method completes, it returns an IRandomAccessStream that contains the requested random-access stream.
If you simply want to open a file in your app, see the OpenAsync method of the StorageFile class.
Using this method, a file can be accessed by both file readers and writers simultaneously. The following is a table describing the situations for various parameter settings of FileAccessMode and StorageOpenOptions:
FileAccessMode | ||
---|---|---|
StorageOpenOptions | Read | ReadWrite |
None | A reader which is lower priority than a writer. If a write occurs, this low priority reader will fail. | This is a single writer. The file cannot be opened if OpenAsync(Read, AllowOnlyReaders) has been used, and it will prevent a new OpenAsync(Read, AllowOnlyReaders) from being used. |
AllowOnlyReaders | A reader which can only exist with other readers. If an open is attempted with a writer, it will fail. | This is a single writer. The file cannot be opened if OpenAsync(Read, AllowOnlyReaders) has been used, and it will prevent a new OpenAsync(Read, AllowOnlyReaders) from being used. |
AllowReadersAndWriters | A reader which can exist with other readers and writers simultaneously. | This writer will invalidate low priority readers when a write occurs and can coexist with other readers and writers. |