获取URI中StorageFile存储的文件(WinRT的)(Get URI for a store

2019-07-29 07:58发布

我建立一个Metro应用,我试图将其保存在StorageFile后获得的图像的开放的,这是我的代码:

StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("samplefile.dat", CreationCollisionOption.ReplaceExisting);

IRandomAccessStream raStream = await file.OpenAsync(FileAccessMode.ReadWrite);
IOutputStream outStream = raStream.GetOutputStreamAt(0);
DataWriter dw = new DataWriter(outStream);
dw.WriteBytes(img); // I'm saving array of bytes
await outStream.FlushAsync();

我读这篇文章:

它说,我可以访问使用MS-应用程序数据存储的文件,所以我想这:

Uri uri = new Uri("ms-appdata:///samplefile.dat", UriKind.Absolute);

但它不工作

Answer 1:

假设它存储在本地文件夹中,URI应该是

Uri uri = new Uri("ms-appdata:///local/samplefile.dat");

注意中间的额外的“本地”。



文章来源: Get URI for a stored file in StorageFile (WinRT)