How do I choose files from the local filesystem in Windows Phone 7

血红的双手。 提交于 2020-01-14 04:44:09

问题


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

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.

Anyone had any luck with the OpenFileDialog and ShowDialog in Windows Phone 7?


回答1:


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.

See MSDN: http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks(VS.92).aspx




回答2:


The OpenFileDialog and SaveFileDialog are explictly not supported in Windows Phone. See Base Controls. Also worth reading is Differences Between Silverlight on Windows and Windows Phone




回答3:


This demo app for upload/download of files from isolated storage to your pc demonstrates navigation of the isolated storage file system.

Reference.



来源:https://stackoverflow.com/questions/2489890/how-do-i-choose-files-from-the-local-filesystem-in-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!