获取StorageFile(WinRT)中存储文件的URI [英] Get URI for a stored file in StorageFile (WinRT)

查看:209
本文介绍了获取StorageFile(WinRT)中存储文件的URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Metro应用,并且在将图像保存到StorageFile之后尝试获取图像的Uri,这是我的代码:

I'm building a metro app, and I'm trying to get a Uri of an Image after saving it in the StorageFile, this is my code:

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访问存储的文件,所以我尝试了此操作:

and it says I can access the stored files using ms-appdata, so i tried this:

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

但它不起作用

推荐答案

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

Assuming it is stored in the Local folder, the URI should be

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

请注意中间的其他本地".

Note the additional "local" in the middle.

这篇关于获取StorageFile(WinRT)中存储文件的URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆