Daniel
Daniel

Reputation: 13

Open a file in the browser from Silverlight

I have a Button (or a hyperlinkbutton) in Silverlight. I want to open a file on a server share when this butto in clicked. With other words I want a new Browser Tab or Window to open showing the requested file, just like I enter the URL in the browsers addressbar:

file://C:\myfile.txt

I tried in the OnClick Method the following:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(@"file://C:\myfile.txt"),"_blank");

it throws an Exception (Access denied). When I do the same with an http: page it works:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(@"http://www.somedomain.com"),"_blank");

How can I achive the same with a file. Security can not be an issue, I have full access to that file. And please don't tell me that this is not possible... would mean we have to go back to PHP.

Upvotes: 1

Views: 3640

Answers (2)

AAbhishek
AAbhishek

Reputation: 11

Silverlight runs on the client side and in by default in LOW trusted mode which dont allow application to access local file system. For the purpose, u can try giving full trust to the silverlight application.

Upvotes: 1

Mr47
Mr47

Reputation: 2655

Firefox does not allow external URLs to link to a local resource anymore :(

Upvotes: 0

Related Questions