如何在Windows应用商店应用中访问文件! [英] How Can I Access File In Windows Store App!

查看:107
本文介绍了如何在Windows应用商店应用中访问文件!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

如何在不使用FileOpenPicker控件的Windows应用商店中访问文件。

在c#中这样:

< pre lang =c#> string [] filelist = Directory.GetFiles( @ d:\);
FileStream fs = new FileStream( @ D:\ab.jpg,FileMode.OpenOrCreate,FileAccess.ReadWrite);
FileStream fs2 = new FileStream(filelist [ 0 ],FileMode.OpenOrCreate,FileAccess.ReadWrite );



谢谢!

解决方案

我想您可以尝试访问appData下LocalFolder下的选项。例如,有一些方法,如CreateFile,GetFileAsync,OpenFileAsync等。



等待ApplicationData.Current.LocalFolder.CreateFileAsync(fileName,CreationCollisionOption.ReplaceExisting);





尝试使用GetFileAsync并根据您是否获得有效的o / p或命中异常,您可以继续前进。

请查看 http://msdn.microsoft.com/ en-us / library / windows / apps / windows.storage.applicationdata.aspx [ ^ ]了解有关应用数据的更多信息


Hi!
How can i access file in Windows store app not using the FileOpenPicker control.
Like this in c#:

string [] filelist = Directory.GetFiles(@"d:\");
FileStream fs = new FileStream(@"D:\ab.jpg", FileMode.OpenOrCreate, FileAccess.ReadWrite);
FileStream fs2 = new FileStream(filelist[0], FileMode.OpenOrCreate, FileAccess.ReadWrite);


Thank you!

解决方案

I think you can try accessing options under the LocalFolder under your appData. For example there are methods like CreateFile, GetFileAsync, OpenFileAsync etc.

await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);


Try using GetFileAsync and based whether you get a valid o/p or hit exceptions you can move forward with what you want to do.
Do check http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.aspx[^] for more information on Application Data


这篇关于如何在Windows应用商店应用中访问文件!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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