Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the path of every explorer window with c#

Tags:

c#

path

I'm very new with C#.

I was boring that sometimes I close a window and after few seconds I note that I need that window again, and is very frustrating to me to reopen Windows Explorer and navigate to that specific path.

So I want to create a little app that permits me store a list of the last closed windows. And with a key shortcut restore one by one the last closed windows (just like I do with browsers like Firefox) and with other key shorcut display a list with the last n windows.

I don't know how to get the paths of the windows and is important that the program gets also when the paths changed (when the user navigates).

Thanks for help.


I will post the link once the app will be finished.

like image 842
Memochipan Avatar asked Dec 15 '11 13:12

Memochipan


1 Answers

Taken from here:

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();

string filename;

foreach ( SHDocVw.InternetExplorer ie in shellWindows )
{
   filename = Path.GetFileNameWithoutExtension( ie.FullName ).ToLower();

   if ( filename.Equals( "explorer" ) )
   {
      // Save the location off to your application
      Console.WriteLine( "Explorer location : {0}", ie.LocationURL );

      // Setup a trigger for when the user navigates
      ie.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(handlerMethod);
   }
}
like image 65
Garrett Vlieger Avatar answered Nov 04 '22 19:11

Garrett Vlieger