IFolder Interface

IT Hit WebDAV for .NET

Represents a folder in the WebDAV repository.

For a list of all members of this type, see IFolder Members.

[Visual Basic]
Public Interface IFolder
    Implements IHierarchyItem
[C#]
public interface IFolder : IHierarchyItem

Remarks

Defines the properties and methods that WebDAV server folder objects must implement. In addition to methods and properties provided by IHierarchyItem this interface also provides methods for creating WebDAV items (folders and resources) and enumerating its children.

Example

    public class Folder : HierarchyItem, IFolder, IFolderLock
    {
        public Folder(DirectoryInfo directory)
            : base(directory)
        {
        }

        #region IFolder Members

        public IHierarchyItem[] Children
        {
            get
            {
                ArrayList children = new ArrayList();

                DirectoryInfo directory = (DirectoryInfo)fileSystemInfo;
                FileSystemInfo[] aFSI = directory.GetFileSystemInfos();
                foreach(FileSystemInfo item in aFSI)
                {
                    if (item is DirectoryInfo)
                        children.Add(new Folder((DirectoryInfo)item));
                    else
                    {
                        if( (item.Attributes & FileAttributes.Temporary)!=0 )
                            children.Add(new LockNull((FileInfo)item));
                        else
                            children.Add(new Resource((FileInfo)item));
                    }
                }
        
                return (IHierarchyItem[])children.ToArray(typeof(IHierarchyItem));
            }
        }

     public WebDAVResponse CreateResource(string name)
     {
        DirectoryInfo directory = (DirectoryInfo)fileSystemInfo;

         using(FileStream fileStream = new FileStream(
                 directory.FullName + "\\" + name, FileMode.CreateNew))
            {
            }

         return new CreatedResponse();
     }

        public WebDAVResponse CreateFolder(string name)
        {
            DirectoryInfo directory = (DirectoryInfo)fileSystemInfo;
            directory.CreateSubdirectory(name);
            return new CreatedResponse();
        }
        #endregion

        #region IFolderLock Members

        public WebDAVResponse CreateLockNull(string name, ref LockInfo lockInfo)
        {
            DirectoryInfo directory = (DirectoryInfo)fileSystemInfo;
            FileInfo file = new FileInfo(directory.FullName + "\\" + name);
            FileStream fileStream = file.Create();
            file.Attributes |= FileAttributes.Temporary; // mark as lock-null item
            fileStream.Close();
            return new CreatedResponse();
        }

        #endregion

        public override WebDAVResponse Delete()
        {
            ((DirectoryInfo)fileSystemInfo).Delete(true);
            return new NoContentResponse();
        }
    }
    

Requirements

Namespace: ITHit.WebDAV.Server

Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll)

See Also

IFolder Members | ITHit.WebDAV.Server Namespace