To accomplish this I've been right-clicking the file or directory and then selecting Show in Windows Explorer, and then copying the path out of the address bar.
Is there an add-on or macro that can make this task easier?
I'm aware that you can drag a file from Solution Explorer into the editor and it will write out the path, but when doing web development I don't always want the server path, sometimes I want the local path.
You can just select the file in the 'Solution Explorer' file list and hit CTRL+C. It automatically copies the file path to your clipboard.
2
I've found one more option of how to solve it without plugins (for VS 2015 and above; not certain about previous versions) Go to "Tools" -> "Customize..." -> "Commands" tab. Choose "Context menu:" and "Project and Solution Context Menus | Item" and you can add any existing Command.
In order to copy path, choose Category "File" and "Copy Full Path" command. Will add button only for files in Solution Explorer. This works for projects as well but you should choose "Project and Solution Context Menus | Project" (copy path of .vcxproj file).
It doesn't work for solutions and I don't understand actually why.
1,45011 silver badges19 bronze badges
1
Tools > Options > Environment > Keyboard
You can set your own shortcut keys for anything. The two that are most relevant to this post are "File.CopyFullPath" and "File.CopyRelativePath". I created my shortcut to just be used in "Text Editor" and it has worked great.
This was asked for VS2010 and I'm using VS2019, so it is an old question, but still relevant. I knew about the file header right click menu, but for some reason I didn't think about the shortcut keys until I read this question. Posting in case this results in a quicker fix for anyone else.
1
The CTRL+C doesn't work for me on MSVS 2017. Use the copy as path extension here. Then right click on file in solution explorer -> Copy as path (or assign a shortcut). I find that it works very well.
You can right click at these 2 places:
- on the tab of the opened file at the top of the screen
- on the file name in the file explorer (usually on the left).
The keyboard shortcuts are the same in both places
There are 2 options:
- Copy Path. Keyboard shortcut
Opt Cmd C
on Mac - Copy Relative Rath. Keyboard shortcut Shift
Opt Cmd C
on Mac
This was already mentioned in other answers, but I wanted to give it more visibility, as this is the simplest way in my opinion.
Raphael PinelRaphael Pinel
2,8302 gold badges27 silver badges35 bronze badges
Explore related questions
See similar questions with these tags.