I have a Windows forms desktop application with a webBrowser control. I navigate to a directory on the server webBrowser1.Navigate(new Uri("\\\\srvername\\share\\directory\\"))
to allow users to open files from that directory.
When they double click on files they get a Windows Security message every time.
When they click OK, the file opens as desired.
If I set navigate to a local directory webBrowser1.Navigate(new Uri("C:\\Temp\\"));
I don't get the message.
Is there a programmatic way to prevent this from showing or is this something that will have to be added to the browser as a trusted site? Standard users on our network don't have access to add trusted sites. I have tried to check the "Include all network paths UNC" in the local intranet section of IE.
I have tried
webBrowser1.ScriptErrorsSuppressed = true;
but that doesn't work as it seems to be meant for script errors happen from a webpage displayed in the control.
Well I found two resolutions to my question.
Is it possible? As @jacob and all my research suggests, I don't think it is. If you are going to use the webBrowser control to view local or UNC path you will have to make changes to IE security or deal with the message for every file that is opened.
Resulution #1
Change security settings in IE. My organization has everything locked down so changes to IE settings can only be made through group policy.
file://servername/*
to the Intranet Zone via group policy for the desired domain OU.Resulution #2
Replace the webBrowser control in my app with other controls that can accomplish the same functionality. This is one I went with so I would have more control over all working of the files and directories. I also don't have to worry about the security settings and group policy enforcement being correct and working correctly. I also don't have to worry about changes in these areas effecting me.
Here is the article I used to get started
The walk through as it is works pretty well. I went through it in a one off project before integrating it into my project. I need to change a few things to suit me. Here is my code as it ended up. I made some changes and added some selecting/clicking events.
It ended up looking like this.
You do lose the icons of known files like Word docs but that is not a big deal to me. You could add icons for the known file types you will have to your imagelist and put some if statements (or switch cases) in the section where it adds items to the listview. Just analyze the file extensions.
Hope this helps somebody someday!