如何使用WinRT获取文件? [英] How to get a file using WinRT?
问题描述
我想要的是
从AppData获取要使用的xml
What I want:
get a xml from the AppData to use
我编写的代码
StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile sampleFile = localFolder.GetFileAsync("abc.xml");
我能得到的
错误:无法将类型"Windows.Foundation.IAsyncOperation"隐式转换为"Windows.Storage.StorageFile"
What I get
Error: Cannot implicitly convert type 'Windows.Foundation.IAsyncOperation' to 'Windows.Storage.StorageFile'
我要检查的内容
此方法成功完成后,将返回一个 StorageFile 代表文件.
When this method completes successfully, it returns a StorageFile that represents the file.
从MSDN
我有什么
Windows 8 Release Preview 64位;
Windows 8的Visual Studio Express 2012 RC;
C#
What I have
Windows 8 Release Preview 64bit;
Visual Studio Express 2012 RC for Windows 8;
C#
我根据MSDN文档编写代码,为什么会发生此错误以及如何解决该错误?
I write the code according to the MSDN doc, Why does this error happen and how to resolve it?
推荐答案
如果您使用的是C#,请尝试使用"StorageFile sampleFile = await localFolder.GetFileAsync("abc.xml")
";如果使用的是JS,请尝试使用"localFolder.GetFileAsnc("abc.xml").done(function (sampleFile) {})
".
Try using "StorageFile sampleFile = await localFolder.GetFileAsync("abc.xml")
" if you're in C# or "localFolder.GetFileAsnc("abc.xml").done(function (sampleFile) {})
" if you're using JS.
这篇关于如何使用WinRT获取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!