Skip to content

UNC Path Naming for files stored on SharePoint

If you didn’t already know, you can access any file stored in SharePoint (2007 or 2010) as though it was a folder on your system. The secret is to make it a network drive. You can do this a couple of ways. The easiest way is to open the library in Explorer. In SharePoint 2010, you’ll find this option in the list ribbon, on the library tab. Depending on the width of your screen, this may only appear as an icon.

image

Once you click on it, you’ll see your files in a regular Explorer Window. Depending on your Explorer settings, you may also see a folder named forms. Do not touch that folder, and do not attempt to add a new folder named forms…. you will break your library. That folder contains the files necessary to properly render the library in a browser. Just pretend that it isn’t there.

Once you do this, your system will “remember” this library and you will be able to to navigate directly to it through the Network node of your Explorer window.

image

You can also add this link directly, by right clicking on your computer in the explorer view, selecting Add Network Location, and entering the URL of your library (or server) there.

image

This is all possible due to the magic of WebDAV (Web Distributed Authoring and Versioning). It’s a protocol for transferring binary files over http and is what is behind the concept of web folders. It’s an interesting acronym because the none of the implementations of the protocol that I’ve ever seen (it’s been around for about 12 years now) have anything at all to do with versioning,but I digress.

For any of this to work,the WebClient service must be running on the client machine, and if you’re using a server operating system, the Desktop Experience must be installed.

This works great for most cases. If you’re opening the files in Word, Excel etc, those applications understand that they’re opening content in SharePoint and they’ll happily write directly back to it……in most cases. The problem is that what is actually happening is that the file is being brought down locally, and synchronized back to the server, or written back directly by the application.

We recently came across a case where we were using an Excel spreadsheet that was stored in SharePoint as a data source in an SSIS (SQL Server Integration Services) process. Everything worked just fine, but the package was not picking up any changes. As it turns out, when we told SSIS the source path of the Excel file, we used the WebDAV address, which was http://server/site/library/filename.xlsx. What then happened was that SSIS pulled down a copy of the file to a temp folder, and then used that file from then on. Not so good.

The fix for this was to use a UNC path (the standard machinenamesharedfolder style). What is the UNC path for a WebDAV folder? It’s not well advertised, but it’s

\ServerURLDavWWWRootSite1NameSite2NameLibraryNameFolderName

Server URL can be a FQDN or a machine name, depending on your configuration, and the site structure begins after DavWWWRoot. The DavWWWRoot is a constant that tells Explorer that it is dealing with WebDav, and must always be present.

It’s probably a good idea to use the UNC path whenever you need to programmatically access files stored on SharePoint.

24 Comments

  1. ORose ORose

    Hi John thanks for the post. I’m running into an issue where I try to open the file from an Office program i.e. Word or Excel and it can’t find the document at the location. “Could no open ‘http://sharepoint/DavWWWRoot/sites/Website1/Shared Documents/book1.xls’. Then it gives me the prompt saying Excel can’t access the file for several reasons: Path does not exist, file being used by another program, workbook has the same name as the currently openeed workbook. The account I am using has site collection administrator rights on the Sharepoint site in question. What I am trying to do is use the UNC path to the document library to grab source excel files for our SSIS package, the exact same way you explained in your post. We have this working in our development environment but that was against a TFS instance of sharepoint. In our test environment we have a 64 bit load balanced environment with MOSS 2007 Enterprise installed. Any assistance on how to fix this problem would be greatly appreciated. Thanks.

  2. John White John White

    I don’t have any bright ideas off the top of my head. My first though would be to check whether the library forces you to use check in/out….

  3. Jonathan Warren Jonathan Warren

    @ORose

    You don’t use DavWWWRoot with HTTP, it’s used with a UNC path. As an example:

    HTTP = http://teams.sharepoint.acme.com/teams/NY/NYC
    UNC = teams.sharepoint.acme.comDavWWWRootteamsNYNYC

    Both of these point to the same library.

    So in the example you give I think it should be:
    sharepoint/DavWWWRootsitesWebsite1Shared Documentsbook1.xls

    Cheers,

    Jonathan.

  4. Jonathan Warren Jonathan Warren

    That should be:
    sharepointDavWWWRootsitesWebsite1Shared Documentsbook1.xls

  5. Tony Braithwaite Tony Braithwaite

    I’m using the UNC to access XML data from an InfoPath form Library using code. When I first try to load a document after the user PC has started then I get a ‘network path not found error’, but if I then open the path in file explorer and re-run the code then it opens the file. SharePoint is running on a different domain.

    Does anyone know how to get the network path recognised without having to manually open the loaction in file explorer.

  6. Pungi Pungi

    Dude, you got a big time typo in the url:
    ServerURLDavWWWRootSite1NameSite2NameLibraryNameFolderName

    Should be:
    ServerURLDavWWWRootSite1NameSite2NameLibraryNameFolderName

  7. John White John White

    Tony – That sounds like an authentication issue to me – have you tried the NET USE command?

    Pungi – Thanks – will fix ASAP

  8. Tony Braithwaite Tony Braithwaite

    Thanks John. I have since discovered that the issue only occurs when running the form in preview. Once it is published to SharePoint there is no problem in another infopath form being opened.

    This is the code I’m using, so if you have any suggestions to improve it I’d be grateful:

    ‘Get form ID from Data Connection to SharePoint library where XML files are held.
    Dim formID As XPathNavigator = Me.MainDataSource.CreateNavigator.SelectSingleNode(“/my:CourseSessionData/my:NewForm/my:CopyPrevGroup/my:SourceCPFID”, NamespaceManager)
    ‘Lookup the file name that correspnds to the ID
    Dim formFileName As XPathNavigator = Me.DataSources(“CoursePlanningForms”).CreateNavigator.SelectSingleNode(“/dfs:myFields/dfs:dataFields/ns1:SharePointListItem_RW/ns1:Title[../ns1:ID = ” & formID.Value.ToString & “]”, NamespaceManager)
    Dim formDoc As XmlDocument = New XmlDocument
    ‘Use server path to form to ensure XML is found and not Infopath template data.
    Dim formpath As String = “Sharepoint.quantum.localDavWWWRootCoursePlanningCourse Planning Forms”
    ‘Need to set up credential resolution to access SharePoint server.
    Dim resolver As XmlUrlResolver = New XmlUrlResolver
    resolver.Credentials = CredentialCache.DefaultCredentials
    formDoc.XmlResolver = resolver

    ‘**** need to trap for file open
    Try
    formDoc.Load(formpath & formFileName.Value.ToString)
    Catch ex As Exception
    MessageBox.Show(“The Infopath form ” & formFileName.Value.ToString & ” that you have requested to copy from is open,” & _
    “please close it and try the copy again”, “Form ” & formFileName.Value.ToString & ” open”, MessageBoxButtons.OK, MessageBoxIcon.Stop)
    Exit Sub

    End Try

  9. […] la librairie SharePoint à mon ordinateur, je peux y accéder via un chemin d’accès universel (UNC Path Naming for files stored on SharePoint) et donc exécuter simplement la tache SSIS sur celui […]

  10. Hi John,

    Nice Article though.I am facing an issue with my production environment.I have bunch of excel file kept in a sharepoint document library and when i am picking these file with my ETL they are getting picked up but once i use the SQL Agent Job to fetch the file,it doesnt read the file though and the ETL is processed.Can you tell me why SQL Agent is not picking the files kept in Document Library

    Thanks
    Ayush khanduri

  11. dear John,

    thanks for your kind article. would like to ask if i can use the UNC file path to upload files back to SharePoint site?

  12. Thank you for the article. It was an interesting read. I am having an issue in our production farm that is slightly different than what you mention above. We are using the Save As feature in Office products (Excel, Word, Etc) and saving the files to a Sharepoint 2010 library using the UNC address. And, what is happening is a file (< 1KB in size) is automatically being added to the recycle bin. I believe our server folks have identified this as on possible cause for backups to be failing. Any idea why we are getting <1KB files automatically created in the Recycle Bin? I can use the Save As feature and the http address that have no issue.

  13. Just wanted to say thanks for posting this. It gave a nice, concise answer from the SharePoint angle for someone who was asking the same question in our organization.

  14. Anonymous Anonymous

    Hi John,

    We have issue with file for reading and process by program which is located in the Sharepoint directory. we use net use \Sharepoint pathxxx directory which give sometimes with permission denied.
    Could you please help us with possible cause and solution.

    Thanks,
    Sudheer

  15. Elisabeth Elisabeth

    You made my day !!!!!
    Thank you so much

  16. Even though this paper was written several years ago, it still applies today in SharePoint 2013. John White, thank you for this well-written and concise explanation as a solution to a problem. I wish more people wrote their solutions in the same fashion. Kudos.

  17. Jude Wong Jude Wong

    I was working on a SSIS solution which involves iterating through items in a SharePoint document library via its UNC path. It was working fine on my development machine but not on the server after it was deployed. The foreach loop container never picked up anything.

    After reading this article on the requirement of the Desktop Experience feature, I installed it on my server, rebooted and the solution worked immediately!

    Thank you!!

  18. Joe B. Joe B.

    Nice post! I’m having an issue with 2010 farm. Check Out is NOT enabled. When I upload through the browser I have no problem, but when I copy/paste via UNC path for the SharePoint site, something is causing them to check out… Any ideas?

  19. Earth Earth

    This concept works great for SSIS package running on my local machine, however when I deploy it to production server; it keeps failing…why?

  20. Isaac Isaac

    I don’t know if anyone else has viewed this page and struggled immensely to apply the advice here, but it seems that the advice given was woefully missing all kinds of slashes and other components! (for me at least?)

    Here is what worked for me:
    \\text.text.text.com@SSL\DavWWWRoot\sites\Site1Name\Site2Name\DocLibName

    …where text.text.text.com is whatever your basic sharepoint url is, Site1Name and Site2Name are if you have a URL that contains like site1\site2, and DocLibName is the name of your doc library.

    hope this helps someone!
    Oh…most importantly, go to your doc library online, click Open in Explorer, once opened, right-click on an actual file contained therein, go to Properties, and view the Location. Bam.

  21. Thanks! Still linking-to in 2021.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.