Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have write code below in silverlight page,its run successfully.

string filepath="http://ServerName/XYZ_FolderName/ABC_FolderName/" + "abc.pdf";

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(filepath), "_blank", "toolbar=no,location=no,status=no,menubar=no,resizable=yes");

But if i have given filepath as a bellow, which are stored in local disc,(not on server like above)

filepath="E:/myfile.pdf"

its showing an error-InvalidOperationException is Denied,Access is denied.

Note: I have full rights of my all drives.
Posted

In Silverlight you can only access local files through a user initiated action (event) using the OpenFileDialog class[^].
 
Share this answer
 
Comments
dev22 19-Oct-11 2:39am    
Hi Mark,

When i am using below code in silverlight .xaml.cs page , its showing an exception on fd.ShowDialog(); line -> SecurityException was unhandled by used code.
Dialogs must be user-initialsed

OpenFileDialog fd = new OpenFileDialog();
fd.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
fd.FilterIndex = 1;
fd.Multiselect = true;
bool? userClickedOK = fd.ShowDialog();
if (userClickedOK == true)
MessageBox.Show("in OpenFileDialog box");
so i am not getting, exactly whats the problem.
Mark Salsbery 19-Oct-11 11:05am    
Yes the OpenFileDialog needs to be user initiated as mentioned by me and in the docs ("For security purposes Silverlight file and print dialogs must be user-initiated. In addition, there is a limit on the time allowed between when the user initiates the dialog and when the dialog is shown. If the time limit between these actions is exceeded, an exception will occur."). User initiated would be in response to a button Click event for example.
you should only use path under your home dir in the server and it is better to use relative path
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900