Link from Document Library to UNC Path

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

I needto 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)
February 11th, 2008 4:11pm

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 Sharepointjust fine if you circumvent that initial validation.

Free Windows Admin Tool Kit Click here and download it now
February 11th, 2008 5:16pm

you can add the Page viewer web part and it will allow you to create a link to a file share

February 21st, 2008 3:03pm

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 Snippetfunction 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

Free Windows Admin Tool Kit Click here and download it now
March 25th, 2008 6:44am

sir, you are the MAN!!! saved me a lot of time. thank you
July 24th, 2008 9:03pm

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..
Free Windows Admin Tool Kit Click here and download it now
July 26th, 2008 10:25pm

Moving this to the Admin forum as it doesn't seem to be anything specially Enterprise ...
July 28th, 2008 6:24am

This can also be done by creating a link using the following for your path file:\\UNCYou 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.
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2008 4:16pm

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

March 30th, 2009 2:41pm

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 hitaccept 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

Free Windows Admin Tool Kit Click here and download it now
August 6th, 2009 5:57pm

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;
        }

October 1st, 2010 2:10pm

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

Free Windows Admin Tool Kit Click here and download it now
October 20th, 2010 1:24am

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?

December 16th, 2010 12:25am

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?

Free Windows Admin Tool Kit Click here and download it now
September 21st, 2011 1:02pm

Hi,

Check out site URL:

http://techtrainingnotes.blogspot.com/2007/08/sharepoint-adding-hyperlinks-to-doc.html

September 26th, 2011 8:48am

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

Free Windows Admin Tool Kit Click here and download it now
August 23rd, 2013 2:44am

you can also use an html file using this article:

http://blogbaris.blogspot.com/2012/01/sharepoint-link-to-file-shares-in.html

April 30th, 2014 6:48pm

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...

Free Windows Admin Tool Kit Click here and download it now
May 29th, 2014 1:26pm

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.

September 11th, 2015 10:08am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics