[Tex/LaTex] How to create an link to a folder

foldersformattinghyperref

I am trying to create a link to a folder such as

C:\Program Files (x86)\7-Zip

I have tried to use href, but as I understand that automatically appends a .pdf to the end.

I tried the solution in hyperref: How to open a directory view with href{…}?

but no success there either. The documentation http://www.tug.org/applications/hyperref/manual.html seems to imply that \url{} can be used for paths. But this just generated a text version of the url.

What is the correct method for linking to a folder? Am I misusing a method or am I not using the correct approach?

Thanks in advance

Best Answer

For local paths:

\href{file:C:/foo/bar/baz/.}

The trailing period looks like a file extension so hyperref doesn't try to be smart and append ".pdf".

For UNC paths you need to double the leading forward-slashes for some reason:

\href{file:////server/share/foo/bar/baz/.}

There's no need to slash-escape embedded space characters in the path.

I haven't been able to get the usually-recommended \href{run:.......} syntax working for directories.

Tested on MikTeX (via Sweave) in Windows 10.