Add Folder to Document Library

I created a document library. I can add new document to the document library. But I want to add folder my sharepoint site. How can I do this? Is it possible?

Hi,
To Create folder inside the document library , Just click on Files Tab at document Library Ribbon.then It will prompt for folder name (enter folder name ) and click on Save.
If you want to create folder through Programmatically, Pls check below link.
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/programmatically-creating-folder-in-sharepoint-document-library/
If you think it is helpful,Vote As Helpful! And if you see a reply being an answer to the question of the thread, click Mark As Answer.
Mahesh

Similar Messages

  • Retrieve all folder & sub folder from document library in sharePoint 2013

    Hi,
    I want to retrieve all the folder and sub folder from document library and bind it to the dropdownlist using server object model.
    I used the below query to get all folder and sub folder.\
    query.Query = @"<Query><Where><Eq><FieldRef
    Name='FSObjType' /><Value Type='Lookup'>1</Value></Eq></Where></Query>";
                      query.ViewAttributes
    ="Scope='RecursiveAll'";
                     query.ViewFields
    = "<FieldRef Name='Title'/>";
                      query.ViewFieldsOnly
    = true;
    but when I bind result with the dropdownlist,it displays the output as below
    Please Help
    Thank You

    Hi,
    Thanks for posting your issue, Kindly try out below mentioned CAML query to get all the Folders and Subfolders from Document Library
    <Query>
    <Where>
    <Contains>
    <FieldRef Name='FileLeafRef' />
    <Value Type='Text'>token</Value>
    </Contains>
    </Where>
    <OrderBy><FieldRef Name='FileDirRef' /></OrderBy>
    </Query>
    <ViewFields>
    <FieldRef Name='ID' />
    <FieldRef Name='LinkFilename' />
    <FieldRef Name='FileDirRef' />
    <FieldRef Name='FileLeafRef' />
    </ViewFields>
    <QueryOptions>
    <ViewAttributes Scope='Recursive' />
    <OptimizeFor>FolderUrls</OptimizeFor>
    </QueryOptions>
    Also, check out below mentioned URLs to fix this issue
    https://social.msdn.microsoft.com/Forums/office/en-US/35e799a1-9360-46e5-8719-dd35fdace7ea/filter-document-library-folder-through-caml-query?forum=sharepointdevelopmentlegacy
    http://www.ktskumar.com/blog/2009/07/retrieve-all-folders-from-list/
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • HT1849 how to add folder to music library on itunes 11.1

    Can some one please help me how to add a folder to music library. I can see add a file to music library option but not folder option.
    Thanks in Advance

    You should be able to add folders via the File > Add To Library menu option - if I go into that and highlight the folder that I want to add in the pop-up dialogue box, then clicking the Open button at the bottom of the dialogue box adds that folder's content to my library

  • How to add folder in picture library programmatically

     
    Hi All,
    I tried to add folder using below code but getting error of "Missing FileLeaf"
    try
                    if (properties.List.Title.ToString() == Utility.ListName.Events.ToString())
                        using (SPSite objSite = properties.Site)
                            using (SPWeb objWeb = properties.Web)
                                SPListItem lstEvent = properties.ListItem;
                                string folderName = Convert.ToString(lstEvent["Title"]) + "_" + DateTime.Now.ToShortDateString();
                                if (!string.IsNullOrEmpty(folderName))
                                    SPList lstEventPictures = objWeb.Lists.TryGetList(Utility.LibraryName.EventPictures.ToString());
                                    if (lstEventPictures != null)
                                        objWeb.AllowUnsafeUpdates = true;
                                        //SPListItemCollection folders = lstEventPictures.Folders;
                                        //folders.Add(lstEventPictures.RootFolder.ServerRelativeUrl 
    , SPFileSystemObjectType.Folder , folderName);
                                        ///* create a folder under the path specified
                                        SPListItem folderItem = lstEventPictures.Items.Add(lstEventPictures.RootFolder.ServerRelativeUrl,
    SPFileSystemObjectType.Folder , folderName);
                                        ///* set the folder name and update */
                                        //folderItem["Title"] = folderName;
                                        folderItem.Update();
                                        lstEventPictures.Update();
                                        objWeb.AllowUnsafeUpdates = false;
                catch (Exception ex)
                    Utility.SPTraceLogError(ex);
    Help me to resolve. Thanks in advance.

    Hi DK,
    You can use below mentioned code to add folder in any of your library. You need to changes little bit code as per your requirement.
    /// <summary>
    /// Provide utilities methods related to folder management
    /// </summary>
    public static class SPFolderUtilities
        /// <summary>
        /// Ensures the specified folder exists.
        /// </summary>
        /// <param name="list">The list where to create the folder.</param>
        /// <param name="subFolderPath">The sub folder path.</param>
        /// <returns>
        /// The existing <see cref="SPFolder"/> or a newly created if it did not exists.
        /// </returns>
        public static SPFolder EnsureFolder(SPList list, string subFolderPath)
            Contract.Requires<ArgumentNullException>(list != null);
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(subFolderPath));
            if (!IO.SPPathUtilities.IsFileOrFolderNameValid(subFolderPath, true))
                throw new ArgumentException("Invalid characters in the file or folder name", "subFolderPath");
            var folderPaths = subFolderPath.Split('/');
            var currentFolder = list.RootFolder;
            for (int i = 0; i < folderPaths.Length; i++)
                currentFolder = list.ParentWeb.GetFolder(currentFolder.Url); // hacky refresh
                var subFolder = currentFolder.SubFolders.Cast<SPFolder>().FirstOrDefault(f => string.Compare(f.Name, folderPaths[i], true) == 0);
                if (subFolder == null)
                    var newFolderItem = list.Items.Add(currentFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, folderPaths[i]);
                    newFolderItem.SystemUpdate();
                    subFolder = newFolderItem.Folder;
                currentFolder = subFolder;
            return currentFolder;
    And here is the specifc code that you can use for Picture library only
    Question
    Vote as helpful
    0
    Vote
    yes the code sample provided by you is to create a image library and then to add a folder to it but i'm not sure with the string.empty being passed to list.items.add. i would still recommend to use the solution suggested by me. to check if library exists or
    not what you have to do is 
    SPSite _MySite = new SPSite("SERVERIP");  
                    using (SPWeb currentweb = _MySite.OpenWeb())
    SPList imageLib = currentweb.Lists["NewImages]
    if( imageLib == null)
    Guid listId = currentweb.Lists.Add("NewImages", "Picture Library", SPListTemplateType.PictureLibrary);
     imageLib t = currentweb.Lists[listId];    
    SPDocumentLibrary
     _MyDocLibrary =
    (SPDocumentLibrary)
    imageLib ;
                     SPFolderCollection _MyFolders = _MyWeb.Folders;
                    _MyFolders.Add("http://adfsaccount:2222/My%20Images/" + <<subfolderName>> + "/");
                    _MyDocLibrary.Update();
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Unable to create a new folder in document library of SharePoint 2010

    Hi There,
    Need some help regarding an issue which is occurring after migration from SP 2007 to 2010.
    We have recently migrated a site to SP 2010, after migration whenever i tried to create a new folder in a document library it gives me an error message below
    SPException: Can not find the form to create default data for the list
        Microsoft.SharePoint.Utilities.SPUtility.ThrowSPExceptionWithTraceTag (UInt32 TagId, ULSCat traceCategory, resourceId String, Object [] resourceArgs) 28098007 
        Microsoft.SharePoint.ApplicationPages.ListFormRedirect.InitializeQueryStringMembers () 1764 
        Microsoft.SharePoint.ApplicationPages.ListFormRedirect.OnLoad (EventArgs e) +25 
        System.Web.UI.Control.LoadRecursive () 66 
        System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 2428
    All the document libraries which are created with the custom list template has this problem. 
    Moreover, I have verified and found Upload.aspx page is available in Forms folder of a document library. 
    Can someone help me in resolving this issue.
    Thank you in advance.
    Vikram
    vikram padigala

    Hi,
    All the document libraries which are created with the custom list template has this problem. 
    Did you mean you had a custom library template?
    Did the issue occur in the library which created use the out of the box template, such as use the Document Library template?
    You can check with the OOB template library to test whether they had the same issue.
    If the OOB template library works well, the issue may be related to the custom library template.
    You can try to recreate a new custom template to check whether it works.
    To quickly and accurately find the issue , you can also check the event log and ULS log to see if anything unexpected occurred.
    For SharePoint 2010, by default, ULS log is at
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Create folder in Document Library using Sharepoint 2010 Client Object Model

    I would like to check for the existence of a folder in s Sharepoint 2010 Document Library and if the folder is not found, create it. (I would then subsequently programmatically upload documents to that folder -- which I have figured out). Can someone
    please help me figure out how to check for the extistence of and then create a folder using the Sharepoint 2010 Client Object Model?

    You can use this:
    public static void CreateFolder_ClientOM(string listName, string folderName)
    ClientContext clientContext = new ClientContext("http://basesmc2008");
    Web web = clientContext.Web;
    List list = clientContext.Web.Lists.GetByTitle(listName);
    clientContext.Load(clientContext.Site);
    string targetFolderUrl = listName + "/" + folderName;
    Folder folder = web.GetFolderByServerRelativeUrl(targetFolderUrl);
    clientContext.Load(folder);
    bool exists = false;
    try
    clientContext.ExecuteQuery();
    exists = true;
    catch (Exception ex)
    if (!exists)
    ContentTypeCollection listContentTypes = list.ContentTypes;
    clientContext.Load(listContentTypes, types => types.Include
    (type => type.Id, type => type.Name,
    type => type.Parent));
    var result = clientContext.LoadQuery(listContentTypes.Where
    (c => c.Name == "Folder"));
    clientContext.ExecuteQuery();
    ContentType folderContentType = result.FirstOrDefault();
    ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
    newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
    newItemInfo.LeafName = folderName;
    ListItem newListItem = list.AddItem(newItemInfo);
    newListItem["ContentTypeId"] = folderContentType.Id.ToString();
    newListItem["Title"] = folderName;
    newListItem.Update();
    clientContext.Load(list);
    clientContext.ExecuteQuery();
    Blog | SharePoint Field Notes Dev Tool |
    ClassMaster

  • Searching for a folder in document library doesn't work properly if the folder is at the root level.

    Hi,
    I have a folder named FS0 on my sharepoint 2013 site. The folder is the first level folder under
    Default Document library (Shared Documents). When I search for FS0 on the sharepoint site, the search result give a link to home.aspx and not the folder. If I search for any folder that is a second level folder in the library, I get a search result that takes
    me inside the folder on clicking it. In my case, I search for a folder named FS1 which directly under FS0. The search result takes me inside FS1 in this case. How can I make the search result display proper links for root level folders also?<o:p></o:p>
    Thanks
    Pranava

    Hi Pranava,
    I couldn't reproduce this issue, when I create root folder FS0 in "Shared Documents" and start a full crawl, I click the FS0 link from search results page, it will open the FS0 folder as well as folder under FS0.
    Please right-click the FS0 name hyperlink (e.g. mine is http://sp/Shared%20Documents/FS0) and paste in IE browser see if it could be accessed successfully.
    Also test if other Shared Documents have this issue in other site collection or web applications, if not, run a full crawl may do a trick (please reset search index if only full crawl still doesn't work).
    Thanks
    Daniel Yang
    TechNet Community Support

  • SharePoint 2013 : Add annotation to document library item

    Hi all,
    Is there a possibility to add annotation to library items. Example, I am sharing a document library item to a user then the user add an annotation and share to another user.  The other user also should add his/her comments on the item.
    Can anyone help me how to achieve this?
    Many thanks & regards
    Vinay

    We've done this in the past using a Rich Text Field in the metadata of the document.  You can set it up so it Appends new entries to the bottom of the field instead of replacing the existing content.  When a user edits the metadata they see a
    blank field.  When they save it their comments are added to the bottom with their name and a timestamp.  We've used it primarily on issues lists, but it should work on a document also.
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • Page not found Error while creating new sub folder in the Sharepoint Document Library

    Hi All,
    I am a site collection administrator when i creating new sub folder under the folder in document library, am getting below error
    "Page not found  The
    page you're looking for doesn't exist."
    please help me, Thanks in advance!!
    Srinivas

    Hi Srinivas,
    Please check ULS log for more useful information when this error occurs.
    Please also check if this issue could be reprodued in other libraries, if not, you can use the new library instead.
    Thanks
    Daniel Yang
    TechNet Community Support

  • Adding a Sharepoint Document Library in Windows Explorer Fovorites

    I want to add a sharepoint document library in my favorites in windows explorer...  Every time I copy the link, instead of opening the library in windows explorer, it open the browser and go directly to the site... Any help would be appreciated.
    Thanks in advance,
    Sebastien

    Hi Seabass:
    Have you tried mapping the library in question as a network location on your local machine? 
    http://windows.microsoft.com/en-us/windows/create-shortcut-map-network-drive#1TC=windows-7
    To map to a particular SharePoint resource on your site, you would use this structure: 
    \\mysharepointsite@80\sites\library\Photos as your network address.
    In this manner, you can add this link to your Favorites, and you will have the Windows Explorer mode you're requesting.  Hope this helps!  ;)

  • Changing Document Library Title via PowerShell

    Hi there,
    I´m trying to add a new Document Library in my SharePoint 2013 environment and change the title of it, due to URL reasons. 
    The Code:
    $web = Get-SPWeb(“http://sp/s/doc”)
    $list = $web.Lists[“Admin”]
    $list.OnQuickLaunch = $true
    $list.EnableMinorVersions = $true
    $list.Title = “Admin2”
    $list.Update()
    The QuickLaunch and versioning settings just work fine, but the title of the library stays "Admin".
    Any Ideas?
    Thank You!

    Hi hank
    This should be becoz of local resources.
    That could be due to localization. In that case, you should also set TitleResource property:
    field.TitleResource.SetValueForUICulture(new CultureInfo(1033), "My title");
    http://sharepoint.stackexchange.com/questions/24163/how-to-rename-title-column-in-document-library-using-code
    7down
    voteaccepted
    That could be due to localization. In that case, you should also set TitleResource property:
    field.TitleResource.SetValueForUICulture(new CultureInfo(1033), "My title");
    7down
    voteaccepted
    That could be due to localization. In that case, you should also set TitleResource property:
    field.TitleResource.SetValueForUICulture(new CultureInfo(1033), "My title");
    7down
    voteaccepted
    That could be due to localization. In that case, you should also set TitleResource property:
    field.TitleResource.SetValueForUICulture(new CultureInfo(1033), "My title");
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Can you add metadata to a folder in a document library?

    I am making a visual webpart for SharePoint 2010 that displays files and folders from a document library, and I want to keep ordering to folders. I want to be able to sort folders so I need a way to store the order number of a folder. If I check on sharepoint
    in the browser, I don't see a way to add any info to it.
    Is there a way to do this programatically in c#?
    I want to avoid keeping the order number as a part of the folder name, something like: "1. Folder A"
    Does anyone know if this is possible?

    Refer to the following post, hope it helps
    http://www.sharepoint-guru.com/2007/06/adding-metadata-to-folder.html
    --Cheers

  • Creating a folder for a document library in SharePoint online

    Hello I am looking for a good place to get started on creating a folder for a document library using a powershell script. Thanks in advance for any help.

    Here is a guide to creating folders and items in a document library for SharePoint Server/Foundation: Creating SharePoint Folders
    and Items with PowerShell. You will need to tailor it to your needs as it's a demo for creating 50,000 items.
    That's step 1 and contains the bulk of what you would need to do. Here's an example of connecting to a library in SharePoint Online using CSOM: Office
    365 - PowerShell Script to Upload Files to a Document Library using CSOM. You won't be uploading files, but the parts where you connect and get a list are what you're interested in.
    Now you'll combine bits from both of these scripts:
    1. Connect to SPO
    2. Get your list (looks like you need to first get the site collection and then the site)
    3. Create a folder
    I figure it would look something like this (note I haven't tested this at all):
    #Specify tenant admin and site URL
    $User = "[email protected]"
    $SiteURL = "https://tenant.sharepoint.com/sites/site"
    $DocLibName = "DocLib"$FolderTitle = "Example Folder"
    #Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    $Password = Read-Host -Prompt "Please enter your password" -AsSecureString
    #Bind to site collection
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
    $Context.Credentials = $Creds
    #Retrieve list
    $List = $Context.Web.Lists.GetByTitle($DocLibName)
    $folder = $list.AddItem("", [Microsoft.SharePoint.SPFileSystemObjectType]::Folder)
    $folder["Title"] = $FolderTitle
    $folder.Update();
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights

  • How to add a record in document library without upload file.

    Hi,
    how to add a record in document library without upload file?
    Is it possible? I want to create a folders in Document Library but inside folders i do not want to upload a file instead of just i want to create a record. I will map my local file path to the records.
    Can anyone help me on it?
    Thanks & Regards
    Poomani Sankaran

    Hello Sankaran,
    document library is to upload documents, without document you will not be able to add a record or Item to it.
    for your requirement you can use a list and enable folders within the list and maintain the local path of the file as an item in list.
    http://www.sharepointbriefing.com/spconfig/article.php/3834951/Enable-the-New-Folder-Creation-Option-in-SharePoint-Custom-Lists.htm
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • How to get the count of items(folders or documents) in a SharePoint document library and for a folder in any SharePoint document library?

    I need to get a count of documents and folders in a selected document library(the item for EventRecievers for event deleting) and the count of documents in a selected folder(the item for EventRecievers for event deleting) to determine whether the item(document
    library or folder) is empty or not, as I need to use this condition for one of my custom EventReceivers.
    Can you please suggest me the code to do the same?

    Hi.
    Try this:
    class Program
    static void Main(string[] args)
    using (SPSite site = new SPSite("http://z2012net"))
    using (SPWeb web = site.OpenWeb())
    SPList l = web.Lists["List001"];
    List<FolderInfo> res = new List<FolderInfo>();
    getListCount(l.RootFolder, ref res);
    private static void getListCount(SPFolder sPFolder, ref List<FolderInfo> res)
    SPQuery query = new SPQuery();
    query.Folder = sPFolder;
    res.Add(new FolderInfo() { ItemCount = sPFolder.ItemCount, Name = sPFolder.Name, Url = sPFolder.Url });
    SPListItemCollection items = sPFolder.ParentWeb.Lists[sPFolder.ParentListId].GetItems(query);
    foreach (SPListItem item in items)
    if (item.FileSystemObjectType == SPFileSystemObjectType.Folder)
    SPFolder f = sPFolder.ParentWeb.GetFolder(item.UniqueId);
    getListCount(f, ref res);
    class FolderInfo
    public string Url { get; set; }
    public string Name { get; set; }
    public int ItemCount { get; set; }
    Regards,
    Bubu
    http://zsvipullo.blogspot.it
    Please mark my answer if it helped you, I would greatly appreciate it.

Maybe you are looking for

  • Could I have two Time Machine backup disks?

    I have a MacPro with a second internal HD, that I have running Time Machine. I just bought an external drive for backup, which I thought I'd also have running Time Machine.  But I see that TM will not really allow one to use two different drives auto

  • Beryl goes white after logout-login

    Hi, i have just install Beryl and make it run at startup. But when i logout-login on my account the screen goes white. Anyone can help me? Thanks Last edited by plaga701 (2007-05-06 22:23:45)

  • Enable Detail Navigation

    Hi I have created following roles. Role 1 Role 2 Role 3 I have assigned Role 3 to Role 2 Role 2 to Role 1 And Role 1 to my user. Now when i am accessing portal.... It is giving a Tab for Role1. On clicking Role1 tab i get a link for Role 2. But on cl

  • Change Ipod name

    I bought my wife a new 3g Nano. She hooked it up to her computer and itunes to get started. The ipod name is listed as owner. How do you change the name of her specific ipod in itunes or on the ipod? Thanks for the help.

  • Does Cmd+H not hide all applications in Yosemite?

    When I press Cmd+H to hide each open app, it works as expected until I get to the last visible app. Instead of the last app being hidden and showing my desktop, pressing Cmd+H will either toggle (hide/unhide) between the last two apps, or not hide th