none
Link from Document Library to UNC Path RRS feed

  • Question

  • Can anyone tell me if it is possible to create a link from a document library to a UNC path?

     

    I need to establish links to resources in an existing document repository, but Sharepoint presents the following message when attempting to add the link "Enter a valid document name and URL. Valid URLs must begin with 'http:' or 'https:'"

     

    Thanks in advance.

     

    Dave

    • Moved by Mike Walsh FIN Monday, July 28, 2008 6:25 AM Wrong Forum (Moved from SharePoint - Enterprise Content Management to SharePoint - Setup, Upgrade, Administration and Operation)
    Monday, February 11, 2008 4:11 PM

Answers

  • Following are the steps to achieve this.

    1) Create a site content type of type "link to a document" with "Document" as a parent content type.
    2) Add the same to the document library.
    3) Go in the layouts folder open newlink.aspx in Visual Studio IDE
    4) add the following function to the script tag

    Code Snippet
    function HasValidUrlPrefix_Override(url)
            {
                var urlLower=url.toLowerCase();
                if (-1==urlLower.search("^http://") &&
                -1==urlLower.search("^https://") && -1==urlLower.search("^file://"))
                return false;
                return true;
            }

     

     

    5) Replace "HasValidUrlPrefix" to "HasValidUrlPrefix_Override" in the newlink.aspx
    6) IISReset and when adding a link to a file share. It shoudl be done in the following format "file://\\{ComputerName}\\}FileName}" it should work
    7) Change the wss resource file present in app_globalresources to show the following message "Enter a valid document name and URL.  Valid URLs must begin with 'http:' or 'https:' or 'file://'"

     

    Hope this should help.

     

    Regards,

    Mayur

    Tuesday, March 25, 2008 6:44 AM
  • Or you could create a shortcut (.lnk) file to the UNC share. You may need remove .lnk from the blocked file types.

    Upload the .lnk file to your library and you are good..
    Saturday, July 26, 2008 10:25 PM

All replies

  • One approach would be to disable the part of the underlying Javascript that provides that validation in that dialog. If you do a search for 'a word or phrase in the file' under the 12 hive and look for "https", there are several Javascript files there containing such validation.

     

    I've never done this myself, so it's a little experimental, but easy enough to roll back if it has undesired results. I think your UNC path will be stored in Sharepoint just fine if you circumvent that initial validation. 

     

    Monday, February 11, 2008 5:16 PM
  • you can add the Page viewer web part and it will allow you to create a link to a file share

    Thursday, February 21, 2008 3:03 PM
  • Following are the steps to achieve this.

    1) Create a site content type of type "link to a document" with "Document" as a parent content type.
    2) Add the same to the document library.
    3) Go in the layouts folder open newlink.aspx in Visual Studio IDE
    4) add the following function to the script tag

    Code Snippet
    function HasValidUrlPrefix_Override(url)
            {
                var urlLower=url.toLowerCase();
                if (-1==urlLower.search("^http://") &&
                -1==urlLower.search("^https://") && -1==urlLower.search("^file://"))
                return false;
                return true;
            }

     

     

    5) Replace "HasValidUrlPrefix" to "HasValidUrlPrefix_Override" in the newlink.aspx
    6) IISReset and when adding a link to a file share. It shoudl be done in the following format "file://\\{ComputerName}\\}FileName}" it should work
    7) Change the wss resource file present in app_globalresources to show the following message "Enter a valid document name and URL.  Valid URLs must begin with 'http:' or 'https:' or 'file://'"

     

    Hope this should help.

     

    Regards,

    Mayur

    Tuesday, March 25, 2008 6:44 AM
  • sir, you are the MAN!!! saved me a lot of time. thank you
    Thursday, July 24, 2008 9:03 PM
  • Or you could create a shortcut (.lnk) file to the UNC share. You may need remove .lnk from the blocked file types.

    Upload the .lnk file to your library and you are good..
    Saturday, July 26, 2008 10:25 PM
  • Moving this to the Admin forum as it doesn't seem to be anything specially Enterprise ...
    Monday, July 28, 2008 6:24 AM
  • This can also be done by creating a link using the following for your path    file:\\UNC You can do this in your navigation tree or a link library or a form library. However if you create it in your link library the "file:" is put there automaticly. Hope this helps. 
    Wednesday, September 3, 2008 4:16 PM
  • If I send the link of a LINK content type in an email message, the user cannot open the file by clicking on the link in the message.  Copying and pasting this link in the browser works fine. 

     

    An example is the NewPresentation link at:

    http://portal1/sites/sales/Docs/NewPresentation.aspx

     

    This does not work if you click on it, but works if you cut and paste it in a browser.

    Do you see a way around this?

    Thanks in Advance,
    Veera Reddy Kolan

    Monday, March 30, 2009 2:41 PM
  • Hi there,

    I recently ran into a very simlar problem and ended up finding a quick work around for it one which doesn't require you to insert any additional functions(i didn't have the permissions to do this on the site). Here's what I did, so far it seems to be working fine.

    1) Create a new document link (ie. New->Link to a new document...in a shared workspace)

    2) When it asks for the url enter anything that it will accept(i used http://google.com). This will get you past the error with http: not being found

    3) Now click accept and go back to the main screen. Then edit the properties of this link; here is should give you the option to change the URL again. Enter the file://<comptername><filename.xls> component here. This time when you hit accept it will not check for "http:" in your field.

    4) Give the new link a try. If it works anything like it did with me then you should be good to go

    • Proposed as answer by MrThomDisco Thursday, March 23, 2017 10:06 PM
    Thursday, August 6, 2009 5:57 PM
  • Has any one managed to get the above working in SharePoint Foundation 2010 as the code above is not working after we have upgrade to SharePoint Foundation 2010. Any info on this would be very usful to us right now.

    This is the code i'm refering to above

     

    function HasValidUrlPrefix_Override(url)
            {
                var urlLower=url.toLowerCase();
                if (-1==urlLower.search("^http://") &&
                -1==urlLower.search("^https://") && -1==urlLower.search("^file://"))
                return false;
                return true;
            }

    Friday, October 1, 2010 2:10 PM
  • I don't think you can upload .LNK files for Document libraries - it only works for Lists.

    http://admincompanion.mindsharp.com/BillBlog/Lists/Posts/Post.aspx?ID=68

    Wednesday, October 20, 2010 1:24 AM
  • if you have a sharepoint document library say at

    https://mycompany/sites/FinanceDpt/Documents

    is there a way to use that as a file share like

    \\https://mycompany/sites/FinanceDpt/Documents ?

    I've tried and doesn't work. Is this not possible?

    Thursday, December 16, 2010 12:25 AM
  • This does not work, for me anyway. On SharePoint 2010 the URL field is html encoded and the resulting value of entering a UNC path becomes file:////{servername}/{file}

    As a result I the redirect fails.  Anyone else have this problem, or a solution?

    Wednesday, September 21, 2011 1:02 PM
  • I had a similar issue where I wanted sharepoint to use a .dot file on a UNC / shared drive. This was a nightmare, as it would open and edit the .dot itself (not good) Then I found this article, where you link to a .lnk file that points to the .dot file on the \\ shared \ drive


    so simple, just create a shortcut and hyperlink to that instead of the .dot

    http://support.microsoft.com/kb/278627/en-us

    Friday, August 23, 2013 2:44 AM
  • Wednesday, April 30, 2014 6:48 PM
  • Although I don't think .lnk files are harmful, we just had our farm evaluated by Microsoft Reps and they consider changing the blocked file types a 'high' risk.

    Just FYI...


    Herschel

    Thursday, May 29, 2014 1:26 PM
  • In SharePoint 2007, it was possible to add file://... in the Link to document content type using this trick (no need of code):
    - At first, enter http://
    - Then, modify the properties and change http:// to file://

    In SharePoint 2013 / Office 365, this trick also works but when you click on the link it opens a blank page sadly.

    Therefore to make it work in SharePoint 2013, the only way would be to use the .lnk workaround.

    1) You will need to remove the blocked file lnk. I wouldn't worry, read Joel Oleson who is not scarred to do it http://www.collabshow.com/2013/10/31/sharepoint-2013-and-office-365-sharepoint-online-file-size-limits-on-folders-and-list-restrictions/ and in Office 365 there are just a 6 blocked file types https://support.office.com/en-au/article/Types-of-files-that-cannot-be-added-to-a-list-or-library-30be234d-e551-4c2a-8de8-f8546ffbf5b3.

    2) You need to run this PowerShell code in order to be able to open the file from the library (with buttons open/save/cancel) otherwise you will need to save the file.

    $webApplication = Get-SPWebApplication "http://your web app"            
    $webApplication.AllowedInlineDownloadedMimeTypes.Add("application/octet-stream")          
    $webApplication.Update()

    Hope it helps somebody.

    Friday, September 11, 2015 2:07 PM
  • it helped me :) thanks...
    Tuesday, January 19, 2016 2:37 PM
  • This worked for me... I wasn't about to muck around in VS.
    Thursday, March 23, 2017 10:06 PM
  • Thanks Mayur,

    it working fine. 

    i have one issue after saving item.

    when i click on Saved item it's not redirect to saved link ( Ex: file://192.168.0.39/share/SharePoint/Learning_Center_Fact_Sheet.pdf).  

    Friday, September 14, 2018 11:15 AM