locked
How to add folder from UNC to Document Library (Shared Documents) RRS feed

  • Question

  • Hi,

    Is it possible to add a new folder to my Shared Documents (SharePoint) from my network shares? Let's say i have this \\10.238.150.94\My Pictures and i want to add this folder to my Shared Documents.

    Regards.

    Monday, November 1, 2010 8:37 AM

Answers

  • Try adding a Page Viewer Web Part to the page.  After adding the web part to the page click on "Open the tool pane", and in the tools pane point the Page Viewer Web Part to file://servername/sharename. This will allow you to see the contents of the file server on your SharePoint site.

    Monday, November 1, 2010 9:17 AM

All replies

  • It should be possible using the object model. And you can even trasfer the files from the network share to the library if you want (provided you have read access to it).

    Something like the following will help:

    SPSite site = new Microsoft.SharePoint.SPSite("http://localhost");      
    SPWeb spWeb = site.RootWeb;
    
    SPList docLib = spWeb.Lists["Document_Library_Name"];     
    SPListItem folder = docLib.Folders.Add(docLib.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, "My folder");
    folder.Update();
    
    using (FileStream fs = File.OpenRead (@"file_path"))
    {
          SPFile file = folder.Folder.Files.Add("TestDoc.doc", fs);
          file.Update(); 
    }

     

    Monday, November 1, 2010 8:55 AM
  • Thanks Farhan_Ansari. But I'm a bit poor in terms of scripting thing. Any idea without touching the script?

    Best Regards

    Monday, November 1, 2010 9:04 AM
  • Try adding a Page Viewer Web Part to the page.  After adding the web part to the page click on "Open the tool pane", and in the tools pane point the Page Viewer Web Part to file://servername/sharename. This will allow you to see the contents of the file server on your SharePoint site.

    Monday, November 1, 2010 9:17 AM