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.

asked Apr 14, 2011 at 19:21

leeand00's user avatar

leeand00leeand00

26.4k45 gold badges155 silver badges304 bronze badges

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.

answered Oct 10, 2016 at 10:58

capawaky's user avatar

capawakycapawaky

1272 silver badges8 bronze badges

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.

J. Murray's user avatar

J. Murray

1,45011 silver badges19 bronze badges

answered Sep 29, 2019 at 11:02

Andrii Radchenko's user avatar

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.

answered Jan 21, 2022 at 1:47

maru's user avatar

marumaru

2062 silver badges6 bronze badges

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.

answered Oct 21, 2020 at 15:43

KeyC0de's user avatar

KeyC0deKeyC0de

5,28710 gold badges52 silver badges73 bronze badges

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

Screenshot of context menu in top tab bar

Screenshot of context menu in file explorer

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 Pinel's user avatar

Raphael PinelRaphael Pinel

2,8302 gold badges27 silver badges35 bronze badges

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.