FoxHills MIcro
FoxHills MIcro

Reputation: 51

Can't find an OpenSequentialWriteAsync() method on StorageFile

This is written in C++/winRT which will eventually replace C++/CX. The following 3 lines of code precede what should be a request to OpenSequentialWriteAsync(). but alas, there is not such command, only OpenSequentialReadAsync().

Is there a reason that creating a sequential file is not allowed???

StorageFolder _storageFolder = ApplicationData::Current().LocalFolder();    

StorageFolder _turboCalc = co_await _storageFolder.CreateFolderAsync(L"TurboCalc", CreationCollisionOption::OpenIfExists); //create sub folder in folder

StorageFile  _storageFile = co_await _turboCalc.CreateFileAsync(L"FileDoubles.dbo", CreationCollisionOption::ReplaceExisting); //create file in sub folder

Upvotes: 0

Views: 94

Answers (1)

Peter Torr
Peter Torr

Reputation: 12019

Windows has different caching strategies for files. As noted at that link (this is for CreateFile, which is at a lower level than StorageFile):

Specifying the FILE_FLAG_SEQUENTIAL_SCAN flag can increase performance for applications that read large files using sequential access. Performance gains can be even more noticeable for applications that read large files mostly sequentially, but occasionally skip forward over small ranges of bytes. If an application moves the file pointer for random access, optimum caching performance most likely will not occur. However, correct operation is still guaranteed.

So using the OpenSequentialReadAsync method can give you performance gains if you really are reading a file sequentially. There is no equivalent optimization for writing, so you can just use OpenAsync.

Upvotes: 1

Related Questions