IHierarchyItem.Parent Property

IT Hit WebDAV for .NET

Gets the parent folder of the item in repository (null for the root of the repository).

[Visual Basic]
Property Parent As IFolder
[C#]
IFolder Parent {get;}

Example

    public abstract class HierarchyItem : IHierarchyItem, ILock
    {
        protected FileSystemInfo fileSystemInfo;

        public HierarchyItem(FileSystemInfo fileSystemInfo)
        {
            this.fileSystemInfo = fileSystemInfo;
        }

        public IFolder Parent
        {
            get
            {
                string storageRootFolder = ConfigurationManager.AppSettings["StorageRootFolder"].TrimEnd('\\');
                string parentPath = fileSystemInfo.FullName.TrimEnd('\\');
                int index = parentPath.LastIndexOf('\\');
                if (index <= storageRootFolder.Length-1)
                    return null;
                DirectoryInfo directory = new DirectoryInfo(parentPath.Remove(index));
                return new Folder(directory);
            }
        }
        ...
    }
    

See Also

IHierarchyItem Interface | ITHit.WebDAV.Server Namespace