Xaml 获取StorageFile(WinRT)中存储文件的URI
我正在构建一个metro应用程序,并在将图像保存到StorageFile后尝试获取图像的Uri,这是我的代码:Xaml 获取StorageFile(WinRT)中存储文件的URI,xaml,windows-8,windows-runtime,isolatedstoragefile,Xaml,Windows 8,Windows Runtime,Isolatedstoragefile,我正在构建一个metro应用程序,并在将图像保存到StorageFile后尝试获取图像的Uri,这是我的代码: StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("samplefile.dat", CreationCollisionOption.ReplaceExisting); IRandomAccessStream raStream = await file.OpenAsync(File
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 appdata访问存储的文件,所以我尝试了以下方法:
Uri uri = new Uri("ms-appdata:///samplefile.dat", UriKind.Absolute);
但是它不起作用假设它存储在本地文件夹中,URI应该是
Uri uri = new Uri("ms-appdata:///local/samplefile.dat");
注意中间的附加“局部”。