Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Below is the code i am using, it works locally but the web application published to a server it does not work. I have tried impersonation and still nothing. It gives no error message it just does nothing. Any help?
Dim openthis As String = System.Environment.CurrentDirectory
                   Process.Start("Explorer.exe", openthis)
Updated 27-Mar-23 8:52am
virusstorm 12-May-15 13:26pm    
You won't be able to do this from a web application for security reasons. Why do you need to execute the explorer from a web application?
Member 10736689 12-May-15 13:29pm    
I want a user to click a link that takes them to that folder with a list of documents. any ideas on workarounds? My web application has a gridview that gives information on various reports and the folder containing the report. I want them to be able to navigate to the folder with all the files instead of just navigating to the files one by one.
virusstorm 12-May-15 13:32pm    
Use the "file" hyperlink.
Member 10736689 12-May-15 13:33pm    
But this will open the file not the folder right? I need to open just the folder not the files.
virusstorm 12-May-15 13:44pm    
Try just a folder. Your only other option is to mount the directory as a virtual directory in IIS and then enable browsing for it.

That code is running on the server.

If it works, it will open Windows Explorer on the server, where nobody will ever see it.

It might appear to work when you run your site in Visual Studio, but that's only because the server and client are the same computer in that specific case.

There is no way to launch Windows Explorer on the client from server code. And even if there was, the client would not have access to the file system on your server.
Share this answer
Member 10736689 12-May-15 13:35pm    
Thanks for the response. Is there any other way to simulate this process?
Richard Deeming 12-May-15 13:38pm    
If you want the user to view the files in a directory on the server, then you could enable "directory browsing"[^] for that directory.

NB: Make sure you only enable it for the specific directory you want to share.
Member 10736689 12-May-15 13:37pm    
like activeX?
Valery Possoz 12-May-15 14:14pm    
When you say "There is no way to launch Windows Explorer". This is not strictly true. There are ways round this limitation. For example host a clickonce and activate it, once the app is downloaded you can do what ever you want on the client PC...

For example:
HttpContext.Current.Response.ContentType = "application/x-ms-application"
HttpContext.Current.Response.Redirect(clickOnceUrl, False)

See here:

ClickOnce is supported natively by Internet Explorer and Firefox and and Chrome using an extension like "ClickOnce for Google Chrome"
Richard Deeming 12-May-15 14:17pm    
Downloading and installing a (Windows-only) application simply to launch another (Windows-only) application on the client seems somewhat excessive! :)

Not to mention the fact that it still wouldn't let the client access a folder on the server, which seems to be the requirement here.

Use ClickOnce.[^]

You will need to create a console, winform or wpf project and publish it using clickonce.[^]

Once you have a working program that does what you want (ie opening windows explorer) you can redirect from your site to the clickonce url:

HttpContext.Current.Response.ContentType = "application/x-ms-application"
HttpContext.Current.Response.Redirect(url, False)

This will download your program, pass what ever parameters you need in the query string and that's it.[^]

Share this answer
Member 10736689 12-May-15 14:52pm    
thank u i will give it a try

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