私のパッケージに含まれているリソースをロードする正しい方法を理解しようとしています。これに似た質問がいくつかあります(例:Unable to access Asset files in Metro app)。可能であれば、手動で任意のms-appx:\\\
パスを作成する必要はありません。OpenStreamForReadAsyncは、ルートから "The Parameter is Incorrect"で失敗する
// The location of everything in my package.
StorageFolder packageLocation = Package.Current.InstalledLocation;
// The folder I want to load a file from
StorageFolder resources = await packageLocation.GetFolderAsync("Resources");
// I can successfully find the file, and then open a stream.
StorageFile file = await resources.GetFileAsync("Default.xml");
Stream streamFromFile = await file.OpenStreamForReadAsync();
// Also, I can just directly open a stream for the file from the folder.
Stream streamFromFolder = await resources.OpenStreamForReadAsync("Default.xml");
// Error: The parameter is incorrect
Stream streamFromRoot = await packageLocation.OpenStreamForReadAsync("Resources/Default.xml")
私は./Resources/...
、/Resources/...
、ms-appx:///Resources/...
を含む多くの組み合わせを試してみました。なぜそれはルートフォルダからは機能しませんか?
注:まだ確認していませんが、ApplicationData.Current.LocalFolder
などの他の「ルート」フォルダでも同じ問題があるようです。
この瞬間に私が感じる完全かつ完全な怒りは、限界を知りません。ありがとう、とUWP APIからの厄介なエラーのための1つをチョーク。 –