简体   繁体   English

从 silverlight 导航到本地文件 Uri? 例外

[英]Navigate to local file Uri from silverlight? Exception

When i click button in SL app i want to open URI to local file in browser.When browser will navigate to this URI a "browser popup dialog" will appear to ask me if i want to "open-save-save as" this file.当我单击 SL 应用程序中的按钮时,我想在浏览器中打开本地文件的 URI。当浏览器导航到此 URI 时,将出现“浏览器弹出对话框”询问我是否要“打开-保存-另存为”此文件.

I created a pure SL 4 application.Added button.In button click handler i wrote:我创建了一个纯 SL 4 应用程序。添加了按钮。在按钮单击处理程序中我写道:

HtmlPage.Window.Navigate(new Uri("file://C:/Temp/Report.doc",UriKind.Absolute)); HtmlPage.Window.Navigate(new Uri("file://C:/Temp/Report.doc",UriKind.Absolute));

I also tried to write it as我也试着把它写成

HtmlPage.PopupWindow(new Uri("file://C:/Temp/Report.doc", UriKind.Absolute), null, null); HtmlPage.PopupWindow(new Uri("file://C:/Temp/Report.doc", UriKind.Absolute), null, null);

In either cases i have exceptions.在任何一种情况下,我都有例外。

When i manually paste file://C:/Temp/Report.doc in InternetExplorer everything is fine, dialog appears on screen.当我在 InternetExplorer 中手动粘贴 file://C:/Temp/Report.doc 时,一切都很好,屏幕上会出现对话框。

Is it possible to do such thing in Silverlight?是否可以在 Silverlight 中做这样的事情?

A security exception will be thrown because Silverlight can't access your local machine's C:\ .由于 Silverlight 无法访问本地计算机的C:\ ,因此将引发安全异常。 If you want to open a file, you can use the OpenFileDialog .如果要打开文件,可以使用OpenFileDialog However, in Silverlight 4, you can access the filesystem if your application is out of browser .但是,在 Silverlight 4 中,如果您的应用程序out of browser中,您可以访问文件系统

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM