How do I see contents of filesystem directories in Visual Studio Solution Explorer? - visual-studio

We have some files (config, static files, that sort of thing) in our codebase that are kept in the same filesystem tree as our codebase, but are not part of projects (ie, not underneath a project's tree).
We're after a way of easily managing these from within the IDE.
I dimly recall there being a Visual Studio addin that lets you do something like right-click "open explorer here" or something like that. Can't find it, now, and it might not even be for VS 2008.
What are the options, if any?
If only solution-folders could display contents of the filesystem (for example)... Or perhaps there's a "files" project type...?

Solution Explorer Window has a "Show All Files" button, to the left of refresh.

I personally use the Power Commands add-in, which has this functionality along with others that I find helpful. You can find more information and download from here.

Related

How to avoid automatically unfolding of projects in Visual Studio 2010 Solution Explorer

I have all the projects in a solution folded, so you can't see their files in the Solution Explorer. And a file belonging to one of those projects open. Once I browse to that file pane, the project containing the file is automatically unfolded in the Solution Explorer.
Is there a way to avoid that automatic unfolding?
I'm not 100% sure what you're after, but in the VS 2010 options, under "Projects and Solutions/General" there is an option called "Track Active Item in Solution Explorer".
I've just tried unchecking that and, with a mutiple project solution all collapsed, when clicking into an open code file it doesn't open up the project in the solution window. Try that and see if it produces the result you're after.
Let me know if I've misunderstood your question though!

Custom file sorting in VS2010 Solution Explorer

Is there any way to force Solution Explorer in Visual Studio 2010 to sort files alphabetically but in order *.h, *.inl and *.cpp?
I want to have
Dummy.h
Dummy.inl
Dummy.cpp
Emmy.h
Emmy.cpp
Grammy.h
Grammy.cpp
instead of
Dummy.cpp
Dummy.h
Dummy.inl
Emmy.cpp
Emmy.h
Grammy.cpp
Grammy.h
No, there is no such feature built in.
I don't know of any extension or add-in that supports this, either, but I imagine that you could create one. Get started with the Visual Studio SDK, or browse the Visual Studio Gallery for something that serves a similar purpose.
However, the Solution Explorer does support grouping related files (such as headers, resources, and code files) into virtual folders. Turn that feature on by deselecting the second button to the left at the top of the Solution Explorer window labeled "Show All Files".

VS2010 "Add Item" directory change

Is there any way to change the default directory Visual Studio 2010 uses when you add a source file through Add -> New Item?
Add New Item simply adds the item based on which project directory you're currently in or have selected in your Solution Explorer. If you want to change where it gets added then select the target location in the Solution Explorer first.
This behavior is obvious when right-clicking in the Solution Explorer, but it's also the same when using Project -> Add New Item....
Since my comment seems to be the actual answer, I repost:
In the toolbar of Solution Explorer, there's a button "Show all files" (or similar, I'm using the German version). This switches the view to directories, rather than filters. In this view, you can right-click on the desired target folder to add items.
This does not actually change the default directory, but since you have to click somewhere anyway to add an item, this is the easiest approach.
Note that even when only using Visual C++, I'd recommend the Productivity Power Tools extension, which comes with Solution Navigator. In C++, this is not as powerful as with .NET, but it still has several features that are useful in C++ and can fully replace Solution Explorer.
Try going to tools -> options -> Project and Solutions.
I know this post is old... but maybe someone will stumble upon it... like I did today...
I had the same "problem":
I have a dedicated directory for icons.
When I need to add an icon to the resource file, Visual studio takes me to "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
To fix the problem, after I "browsed" to the desired folder, I right-clicked the favorites of the "open file" dialog and selected "add current location to Favorites".
Next time you will get this dialog, you simply have to look for the folder in the favorites, and click it.

How to find files in source control but not in a Visual Studio solution?

I have a rather large Visual Studio 2008 solution in Subversion. It was migrated from Visual SourceSafe a few months ago. I'm starting to find that there are a number of files still in source control that were removed from the solution back when I was using VSS. They were probably renamed or deleted after they were checked out - VSS doesn't like that.
I'm looking for an easy way to find all of the files that are not in the solution but are in Subversion. Something like WinMerge's folder compare would be ideal, where one side is the Subversion working copy and the other side is the project contents.
We haven't upgraded to VS2008 yet, so I'm not sure how much of this applies, but anyway:
Approach 1: On the Solution Explorer toolbar, click "Show All Files." Then highlight the root node of the solution and hit "*" on the numeric keypad to fully expand the tree. The icons that are just outlines are files that aren't part of the solution. From those, you have to determine by hand which are unnecessarily in svn.
Approach 2: Do a "svn export" to create a secondary copy of the project somewhere. Open the new copy with VS and then choose File->Source Control->Change Source Control. In the resulting window, if any projects show as "Connected," highlight them and click "Disconnect" on the toolbar. Close the Source Control window and then, in the Solution Explorer, with "Show All Files" turned OFF, delete everything. The files remaining on disk are the extras your project is no longer using.
With both approaches, it would be smart to make a separate backup copy of the project before doing anything, just in case you nail one too many files.

Can't "go to declaration" in *.ashx files (Visual Studio 2008)

When I open *.ashx files in Visual Studio, I don't have the helpful "Go to Declaration" context menu when right-clicking on a function.
How can I restore this functionality (this is a new install)?
Thanks very much.
Click on the text you want to go to and key F12 if it's not showing up for you.
Much like Windows Operation Systems need to reboot when things start breaking down, Studio sometimes needs a restart if that doesn't work.
Obviously this doesn't get your menu item back, but it's a fix that you might prefer over selecting that from the right-click mouse menu.
This is a shot in the dark since I do not work with ASP-related stuff.
Short Answer
If your *.ashx files belong to a project, open the project first.
Longer Answer
Most of my work in Visual Studio 2008 is with C++ and C# code. If I open a .cpp file or .cs file in VS2008 independent of the project it belongs to, VS2008 doesn't give me the Go To Declaration context menu either. When I open files independent of the project they belong to, VS2008 (or any Visual Studio version for that matter) is little more than a glorified editor. To get the benefit of Go To Declaration and other features, e.g., Intellisense, I have to first open the project and then open the file from within VS2008.
Alternate Answer
If you are already doing this, you might try deleting the .suo file in your project directory and letting VS2008 re-create it.
Apology
Sorry if this was simply stating the obvious. I know I've been frustrated at times when I've opened a file outside the context of its project only to realize what I want to do requires me to open the project anyway. Someone new to Visual Studio might not realize the project is sometimes required.

Resources