开发者

Download a static file in Silverlight 3 without using SaveFileDialog

开发者 https://www.devze.com 2022-12-17 17:25 出处:网络
I have a Silverlight 3 app that that will let users download PDF files of static content.The problem is that the SaveFileDialog in Silverlight 3 does not allow you to specify the default filename that

I have a Silverlight 3 app that that will let users download PDF files of static content. The problem is that the SaveFileDialog in Silverlight 3 does not allow you to specify the default filename that appears in the dialog box. This means that users have to type the name themselves and this is confusing for them since they are accustomed to a "simple" save dialog which only asks them to either Save or Cancel. All 开发者_如何学Cusers are using IE7 or IE8.

I've tried to find a solution by the following methods:

  • Open the file new window using HtmlPage.Window.Navigate hoping to prompt a download (which obviously fails since it opens the file in a new window)
  • Using the SaveFileDialog (which we don't want to use for the aforementioned reason)

How can a file be downloaded in Silverlight such that a user-initiated save dialog only gives users the option to Save/Cancel instead of prompting to type a file name?


This is a well-known issue with SL3 SaveFileDialog. Unfortunately, there is currently nothing on the horizon that says it will get fixed other than someone at MSFT saying something to the effect of "if we have some time, we'll fix it for SL4". There is a bit of a riot by developers over at http://forums.silverlight.net/forums/p/117702/265216.aspx.


Did you try setting the default extension on the SaveFileDialog? See MSDN documentation: http://msdn.microsoft.com/en-us/library/system.windows.controls.savefiledialog.defaultext%28VS.95%29.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号