none
Get current folder name RRS feed

  • Question

  • I want to get current folder name from a document library problematically 

    For Eg: Share Documents

                    -- Folder A

                            ---Folder B

    I would like to check if the parent folder name is Folder A, if the user is in Folder B.

    Thanks.


    • Edited by Nick_4545 Wednesday, February 20, 2013 11:55 PM
    Wednesday, February 20, 2013 11:54 PM

Answers

All replies

  • Try using this in your event handler

    properties.ListItem.Folder.ParentFolder.ToString();


    --Cheers

    Thursday, February 21, 2013 10:45 AM
  • public override void ItemUpdating(SPItemEventProperties properties)
            {
                base.ItemUpdating(properties);
                using (SPSite site = new SPSite("http://yousiteURL"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPDocumentLibrary DocLib = (SPDocumentLibrary)web.Lists["yourDocLibName"];
                        foreach (SPListItem item in DocLib.Items)
                        {
                          SPFile f = item.Web.GetFile(item.Url);
                            
                                    properties.AfterProperties["FolderName"] = f.ParentFolder.Name;
                           
                        }
                    }
                }
            }
    Try this code it works perfectly for me.
    Good Luck
    Friday, October 18, 2013 4:03 PM