ストリームをリソースファイルから取得する正しい/唯一の方法ですか?リソースファイル/コンテンツからストリームを取得する
Uri uri = new Uri(fullPath);
StorageFile storageFile =
await Windows.Storage.StorageFile.
GetFileFromApplicationUriAsync(uri);
IRandomAccessStreamWithContentType randomAccessStream =
await storageFile.OpenReadAsync();
IInputStream resourceStream = (IInputStream)
randomAccessStream.GetInputStreamAt(0);
のすべての私の他の情報源(httpとローカルストレージ)Streamオブジェクトを返し、どちらか一方を使用している場合は、他のコードに持つことが痛いです。
私はMemoryStreamを作成してみましたが、バイトを取得する方法が見つからない...助けてください。
uint size = (uint)randomAccessStream.Size;
IBuffer buffer = new Windows.Storage.Streams.Buffer(size);
await randomAccessStream.ReadAsync(buffer, size,
InputStreamOptions.None);
Stream stream = new MemoryStream(buffer); // error takes byte[] not IBuffer
IInputStream.ReadAsync()リソースからの読み取り時: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.streams.iinputstream.readasync.aspx
Stream.Read()とStream.ReadAsync()は次のようになりながら:
http://msdn.microsoft.com/en-us/library/system.io.stream.read.aspx
と
http://msdn.microsoft.com/en-us/library/hh137813.aspx
ありがとうございました
は流れがStorageFileに変換することも可能ですか? :o – jdnichollsc