Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all

i have a functionality in my website

dynamically show a link specified drive if i click that link it can open in explorer
from client side

in process.start is working only local but when i publish in iis it's not working client side so i want to open client side through shell command or command prompt

C#
public enum ShowCommands : int
   {
       SW_HIDE = 0,
       SW_SHOWNORMAL = 1,
       SW_NORMAL = 1,
       SW_SHOWMINIMIZED = 2,
       SW_SHOWMAXIMIZED = 3,
       SW_MAXIMIZE = 3,
       SW_SHOWNOACTIVATE = 4,
       SW_SHOW = 5,
       SW_MINIMIZE = 6,
       SW_SHOWMINNOACTIVE = 7,
       SW_SHOWNA = 8,
       SW_RESTORE = 9,
       SW_SHOWDEFAULT = 10,
       SW_FORCEMINIMIZE = 11,
       SW_MAX = 11
   }


   [DllImport("shell32.dll")]
   static extern IntPtr ShellExecute(
       IntPtr hwnd,
       string lpOperation,
       string lpFile,
       string lpParameters,
       string lpDirectory,
       ShowCommands nShowCmd);
//in button click event im calling
 ShellExecute(IntPtr.Zero, "open", "explorer.exe", @"F:", "", ShowCommands.SW_NORMAL);


loclally it's working fine but when i hosting iis it's not working

let me know how to sove this

Thanks and advance.........
Posted
Updated 7-Mar-12 6:07am
v3
Comments
Herman<T>.Instance 7-Mar-12 6:45am    
maybe detect it by using WMI or use javascript activex-object

You cannot do it by executing code on the Server - security will not allow you. The code must be executed on the Client.

However, you can do it by putting a link into the HTML:
HTML
<a href="File://D:\Temp\" target="_blank">D:\Temp</a> 
 
Share this answer
 
All ASP.NET code runs on the server, never on the client. So, the code may have worked, but it just opened Explorer on the server.
 
Share this answer
 
Comments
Bojjaiah 7-Mar-12 13:08pm    
but when i hosted in iis it's not working dave!
Dave Kreskowiak 7-Mar-12 13:48pm    
What did I just get done saying?!?!? IT'S NEVER GOING TO WORK BECAUSE THE CODE RUNS ON THE SERVER ONLY! THE SERVER CANNOT LAUNCH A PROCESS ON THE CLIENT MACHINE, EVER!

You can NOT open an Explorer window on the client from server-side code.
Bojjaiah 9-Mar-12 9:13am    
cool..............

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