Footprints in the snow of a warped mind

Visual Studio Tip of the day: Open files/folders in Windows Explorer

Where to find me

Flickr Icon  Twitter Icon  Linked In Icon  FaceBook Icon  Windows Live Alerts Butterfly  RSS 2.0 

The Site Doctor is Hiring!

Enjoy what you read here?
Think you can do better?
Join our team and get paid
up-to £35,000.
Apply now.

Tag Cloud

AJAX (4) Analysis (3) ASP (6) ASP.Net (59) Error Reporting (4) Web Service (2) WSDL (1) Atlas (2) Azure (1) Born In The Barn (1) Business (95) Business Start-up Advice (37) Client (17) Expanding Your Business (24) Recruitment (1) C# (25) Canoeing (4) Canoe Racing (5) Cheshire Ring Race (5) Racing (2) Training (4) Christmas (1) CIMA (1) Cisco (1) 7970G (1) CMS (1) Code Management (1) Cohorts (4) Commerce4Umbraco (1) Content (1) Content Management (1) Content Management System (1) CSS (4) dasBlog (5) DDD (2) DDDSW (1) Design (12) Icons (1) Development (28) Domain Names (1) eCommerce (13) Email (1) Employment (2) Festive Sparkle (1) General (39) Christmas (6) Fun and Games (11) Internet (22) Random (46) RX-8 (8) Git (2) Google (1) Google AdWords (1) Google Analytics (1) Hacking (1) Helpful Script (3) Home Cinema (2) Hosting (2) HTML (3) IIS (11) iPhone (1) JavaScript (5) jQuery (2) LINQPad (1) Marketing (6) Email (1) Multipack (1) MVC (3) Networking (3) Nintendo (1) Nuget (1) OS Commerce (1) Payment (1) Photography (1) PHP (1) Plugin (1) PowerShell (3) Presentation (1) Press Release (1) Productivity (3) Random Thought (1) Script (2) Security (2) SEO (6) Server Maintenance (7) Server Management (12) Social Media (2) Social Networking (3) Experiment (1) Software (11) Office (5) Visual Studio (14) Windows (6) Vista (1) Source Control (2) SQL (13) SQL Server (19) Starting Something New (2) Statistics (2) Stored Procedure (1) Sublime Text 2 (1) SVN (1) TeaCommerce (1) Testing (2) The Cloud (1) The Site Doctor (140) Turnover Challenge (1) Twitter (3) uCommerce (21) Umbraco (38) 2009 (1) 2011 (1) Useful Script (6) Virtual Machine (1) Web Development (72) WebDD (33) Wii (1) Windows Azure (1) XSLT (1)

Blog Archive


<March 2009>

Blog Archive

Various Links


Blogs I Read

[Feed] Google Blog
Official Google Webmaster Central Blog
[Feed] Matt Cutts
Gadgets, Google, and SEO
[Feed] Ol' Deano's Blog
My mate Dean's blog on my space, equally as random as mine but not off on as much of a tangent!
[Feed] Sam's Blog
Sam is one of my younger brothers studying Product Design and Manufacture at Loughborough, this is his blog :) Enjoy!

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

newtelligence dasBlog 2.2.8279.16125

Send mail to the author(s) Email Me (Tim Gaunt)

© 2015 Tim Gaunt.

Sign In

    # Monday, March 02, 2009

    Visual Studio Tip of the day: Open files/folders in Windows Explorer

    Monday, March 02, 2009 11:09:25 AM (GMT Standard Time, UTC+00:00)

    A little irritation/time consuming process when you're working with multiple projects on multiple drives/SVN repos/directories is to open the current file's location within Windows Explorer. If you weren't already aware, you can do this from most projects/files by right clicking on the project in the solution browser:

    Problem for me (and my mate Chris) is that not only is it just for the Project Item but more importantly it means using the mouse -which is something I'm trying to avoid as much as possible. Then I stumbled across a couple of posts which suggested opening Windows Explorer with Visual Studio's External Tools dialog.

    They're both great ideas but you still need to use the mouse so I thought I'd take the final step and wire up some keyboard shortcuts. I'll recap the process here as I've added/grouped a few of their settings.

    Creating the "External Tools"

    There's a little productivity tip here for setting the folder in question the root of Windows Explorer, this encourages you to focus on just the work in question (though it can be a little irritating sometimes so I may "undo" this change later.

    Custom #1: Open the current solution item in Windows Explorer

    Title: Windows Explorer - Item
    Command: explorer.exe
    Arguments: /select,"$(ItemPath)"

    Custom #2: Open the current Visual Studio project in Windows Explorer

    Title: Windows Explorer - Project Directory
    Command: explorer.exe
    Arguments: /root,"$(ProjectDir)"

    Custom #3: Open the current Visual Studio solution in Windows Explorer

    We've got a number of projects that have useful files/folders stored in the same folder as the solution file so this one's useful to get quick access to them, I think I'll use this one a lot when dealing with SVN.

    Title: Windows Explorer - Solution Directory
    Command: explorer.exe
    Arguments: /root,"$(SolutionDir)"

    Custom #4: Open the current solution's binary (bin) directory in Windows Explorer

    Useful when you want to get access to the dll i.e. to copy to another folder/upload just the dll to a website.

    Title: Windows Explorer - Binary Directory
    Command: explorer.exe
    Arguments: "$(TargetDir)"

    Custom #5: Open the current solution's target build directory in Windows Explorer

    This is useful when you have a project that builds to another directory (i.e. a common DLL directory, I'm not sure how many people do this but I've got a couple of projects that do this so I thought I'd share it).

    Title: Windows Explorer - Target Directory
    Command: explorer.exe
    Arguments: "$(BinDir)"

    In all instances you can leave the Initial Directory field empty.

    Note: On a couple of the directory related commands I've set the "/root" argument, this is a useful little productivity tip I learn a while ago to stop you navigating away from your work. Irritatingly I've not found a way of using the /select and /root commands together. It would also be nice to say "Open the bin folder and set the root to the project folder" but again I've not found a way.

    If you're interested in the arguments I'm using there, check out the Microsoft Support article about How To Customize the Windows Explorer Views in Windows XP (these also work in Vista). Alternatively you can read more about the Visual Studio macros for build commands here (some of which are global I believe). I'm interested to see the use of $(TargetDir) as although it'll be useful for non-web projects, however using Web Deployment Projects might make it irrelevant for you.

    You should now have 5 new items in your Tools' toolbar:

    Wire up the keyboard shortcuts

    As mentioned earlier, I want keyboard shortcuts but if you want toolbar icons, you should checkout the end of this post.

    Open up the Keyboard settings within the Visual Studio Option dialog (Tools -> Options -> Environment -> Keyboard) -you may need to select the "Show all settings" checkbox in the bottom left of the Options dialog to see the Keyboard option.

    In the Show commands containing field enter "Tools.ExternalCommand" to list the set of commands, irritatingly it just labels each command as "Tools.ExternalCommand#" for each command so this bit will require a little thinking on your behalf. My commands are #2-6 (#1 is the Dotfuscator Community Edition command).

    I would then wire up the following shortcuts (I've set them up Globally for convenience):

    Tools.ExternalCommand2 (Current Item): Ctrl+E, I
    Tools.ExternalCommand3 (Current Project): Ctrl+E, P
    Tools.ExternalCommand4 (Current Solution): Ctrl+E, S
    Tools.ExternalCommand5 (Bin dir): Ctrl+E, B
    Tools.ExternalCommand6 (Target dir): Ctrl+E, T

    To enter these shortcuts simply press the first combination (in this case Ctrl+E), then press the second key (I -item, P -project, S -solution, B -binary, T -target). I found that a couple of these were already wired up to ReSharper and Pex which is a pain but I don't tend to use those particular shortcuts so I just overrode them

    Now you should be able to press Ctrl+E followed by I and get your current item in Explorer.

    It'd be nice if I could get it to use a single instance of Explorer and just refocus the items (on another key combo as that's not always the desired action).

    Update: After using it a little, I've noticed that in my projects, I had the Bin/TargetDir the wrong way around (now corrected).

    Don't forget to follow me on Twitter.