1

I'm building a custom console with a specialized set of commands for our environment. This console will have a working directory.

I'm toying with the possible [bad] idea of trying to link a windows explorer window's file location to the one in my application.

Such that:

cd somefolder

would navigate the windows explorer window to that folder.

Likewise going into a subfolder in explorer would communicate the information to my app such that I could change my working directory for the console.

Is something like this possible with C#? My app would trigger the opening of the window.

Clarification: I'm referring to a single explorer window that I spawn from my application, not multiple windows. As part of this I am presuming there a way to grab a "handle" to my specific explorer window. Normal ones would behave as normal.

The primary nuance is being able to navigate the already opened window to different locations, not just being able to spawn a window to an initial location.

Joshua Enfield
  • 17,642
  • 10
  • 51
  • 98
  • I imagine you could find the "WindowsExplorer.exe" file and give your desired location as an argument. – Sophie Coyne Mar 09 '16 at 15:31
  • Are you looking for `Process.Start(someLocation)` ? This will open an Explorer Window on the folder you specified. – Panagiotis Kanavos Mar 09 '16 at 15:31
  • 5
    I think that may be possible to archieve but, why don't you just implement a basic explorer in your app? Is not very difficult to do and you'll be in total control – Pikoh Mar 09 '16 at 15:31
  • 1
    What do you want to happen if I have two or three explorer windows open? What if I close all of them? – nvoigt Mar 09 '16 at 15:32
  • 1
    @Rariolu explorer.exe is in the PATH, I doub't you need anything more than `explorer.exe` to star it. Besides, it *is* the default application registgered to handle paths. – Panagiotis Kanavos Mar 09 '16 at 15:32
  • 1
    [This answer](http://stackoverflow.com/a/20961047/1025555) might actually be helpful. – Good Night Nerd Pride Mar 10 '16 at 08:27

2 Answers2

1

Powershell code FYI

$shell = New-Object -ComObject Shell.Application;
$shell.Windows()[0].Navigate("C:\")
SE12938683
  • 196
  • 1
  • 7
0

If your Explorer window is focused, you could do:

SendKeys.SendWait("{F4}^a" + yourPath + "{ENTER}");

It will navigate to your desired path.

doomgg
  • 337
  • 2
  • 8