SharePoint - Link to file shares in Document Libraries

In SharePoint you can't create links to files like file://xxx/ because the link field type only accepts http:// or https://.

If you use Internet Explorer in your company you can use a trick. The network shares are usually mapped to local drives like H:. It is better if you use directly the name of the mapped server folder instead of the local drive letter, so everyone can use the link.

1.Way - Redirect with html file

Create an .html (or .aspx in SharePoint Online) file with the following code and upload it to your document library. It will open the html file which itself opens the folder or file in a new window. With history.back() it returns to your doc lib.

<html>
 <body>
  <script type="text/javascript">
    // mapped network folder H:
    var filer = "file://servername/e$/Folder1/Folder2/Data"    
    // folder within the mapped (which you see in explorer)
    var folder = "/Folder3/Internal/projekts/security"
    
    window.open(filer + folder, "File");
    history.back();
  </script>
 </body>
</html>

2. Way - Modify NewLink.aspx

Another way to archive is posted by Linda Lee Capman here. The core idea is to use the "Link to Document" content type. You can add this content type to your document library and link to other documents. Normally you can enter only http or https links there.

The NewLink.aspx is the page where you enter the link. Here you can modify the javascript function, which checks if the entered URL begins with http or https.

The idea is great, but with cumulative updates or patches the newlink.aspx can be resetted. It would prefer if you make a copy of the newlink.aspx and rename it to newlink_custom.aspx and add the javascript code there.

Newer tested if this functions really, just try.

3. Way - Modify Link

Another easy way to create a link to a filer is to add the "Link to Document" content type into your Document Library.

Now create a link to any document with this content type. After that download a copy of the link to your local computer.
Download a copy of "Link to Document"
Open the downloaded file with your favorite editor. Change the two marked parts and enter the path to your File Share:

Modify Code
Now upload the aspx page again to your library.

Comments

Eugene said…
Thank you for sharing this tip. It does exactly what I'm trying to achieve simply and elegantly! Much appreciated.
Anonymous said…
Thanks a lot for this post. It was precisely what I needed. One comment I want to make is that this will not work as nicely for SharePoint Online because html files need to be Saved before you can Open them (and no way to change this behavior). I tried using an aspx file instead and it worked as exepected then. Thanks!
Anonymous said…
It would be even easier to use the content type "Link to document" and then override the JS Function "HasValidUrlPrefix" and then you can enable all prefixes you want.

Popular posts from this blog

Open SharePoint 2010/2013 Display, Edit, New Forms in Modal Dialogs

Ways to redirect http requests in SharePoint

How to create a FAQ in SharePoint with OOB features