我在winrt中访问文件时遇到一些问题
问题1:
var file = await StorageFile.GetFileFromPathAsync(filePath);
Run Code Online (Sandbox Code Playgroud)
有时,GetFileFromPathAsync将抛出"rpc服务器不可用"异常.
问题2:
MusicProperties musicProp = await file.Properties.GetMusicPropertiesAsync();
Run Code Online (Sandbox Code Playgroud)
有时它会引发异常:
Unable to cast COM object of type 'Windows.Storage.FileProperties.MusicProperties' to interface type 'Windows.Storage.FileProperties.IMusicProperties'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{BC8AAB62-66EC-419A-BC5D-CA65A4CB46DA}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
Run Code Online (Sandbox Code Playgroud)
问题3:
QueryOptions query = new QueryOptions(CommonFileQuery.OrderByMusicInfo, extensionList);
StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(query);
IReadOnlyList<IStorageFile> files …Run Code Online (Sandbox Code Playgroud)