如何从 Windows Phone 7 的本地文件系统中选择文件 [英] How do I choose files from the local filesystem in Windows Phone 7
问题描述
我正在尝试选择一些文件上传到 Windows Phone 7(在模拟器中),任何对 OpenFileDialog 的 ShowDialog 的尝试都会导致安全异常.正在从单击按钮时的事件调用打开文件对话框,但我得到一个
I'm trying to choose some files to upload in Windows Phone 7 (in the emulator), and any attempt to ShowDialog of the OpenFileDialog leads to a Security Exception. The open file dialog is being called from an event on a button click but I get a
SecurityException
[FileDialog_ActiveScripting]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=3.0.40806.0&File=System.Windows.dll&Key=FileDialog_ActiveScripting
在 Silverlight 版本的 OpenFileDialog.ShowDialog 中查找 SecurityException 指出错误是:
Looking up the SecurityException in the Silverlight version of OpenFileDialog.ShowDialog states that the error is:
Active Scripting in Internet Explorer is disabled.
-or-
The call to the ShowDialog method was not made from user-initiated code.
有人在 Windows Phone 7 中使用过 OpenFileDialog 和 ShowDialog 吗?
Anyone had any luck with the OpenFileDialog and ShowDialog in Windows Phone 7?
推荐答案
我相信您需要使用 Microsoft.Phone.Tasks 命名空间中的类.Windows Phone 7 API 不提供通用文件选择器,而是提供特定任务,例如 CameraCaptureTask 或 PhotoChooserTask.
I believe you need to use classes from the Microsoft.Phone.Tasks namespace. The Windows Phone 7 API's do not give you a generic file picker but rather specific tasks such as CameraCaptureTask or PhotoChooserTask.
参见 MSDN:http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks(VS.92).aspx
这篇关于如何从 Windows Phone 7 的本地文件系统中选择文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!