Click or drag to resize

IFolderCreateFolderAsync Method

IT Hit WebDAV Classes Reference
Creates new WebDAV folder with the specified name in this folder.

Namespace:  ITHit.WebDAV.Server.Class1
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 13.3.13068
Syntax
Task<IFolder> CreateFolderAsync(
	string name
)

Parameters

name
Type: SystemString
Name of the folder to create.

Return Value

Type: TaskIFolder
New folder instance created in this call.
Exceptions
ExceptionCondition
LockedExceptionThis folder was locked. Client did not provide the lock token.
NeedPrivilegesExceptionThe user doesn't have enough privileges.
InsufficientStorageExceptionQuota limit is reached.
DavExceptionIn other cases.
Examples

The code below is part of 'WebDAVServer.FileSystemStorage.AspNet' C# & VB samples provided with the SDK.

virtual public async Task<IFolder> CreateFolderAsync(string name)
{
    await CreateFolderInternalAsync(name);

    DavFolder folder = (DavFolder)await context.GetHierarchyItemAsync(Path + EncodeUtil.EncodeUrlPart(name));
    await context.socketService.NotifyCreatedAsync(System.IO.Path.Combine(Path, EncodeUtil.EncodeUrlPart(name)), GetWebSocketID());

    return folder;
}

private async Task CreateFolderInternalAsync(string name)
{
    await RequireHasTokenAsync();
    bool isRoot = dirInfo.Parent == null;
    DirectoryInfo di = isRoot ? new DirectoryInfo(@"\\?\" + context.RepositoryPath.TrimEnd(System.IO.Path.DirectorySeparatorChar)) : dirInfo;
    di.CreateSubdirectory(name);
}
Examples

The code below is part of 'WebDAVServer.FileSystemSynchronization.AspNetCore' C# & VB samples provided with the SDK.

C#
virtual public async Task<IFolder> CreateFolderAsync(string name)
{
    await CreateFolderInternalAsync(name);

    DavFolder folder = (DavFolder)await context.GetHierarchyItemAsync(Path + EncodeUtil.EncodeUrlPart(name));
    await context.socketService.NotifyCreatedAsync(System.IO.Path.Combine(Path, EncodeUtil.EncodeUrlPart(name)), GetWebSocketID());

    return folder;
}

private async Task CreateFolderInternalAsync(string name)
{
    await RequireHasTokenAsync();
    bool isRoot = dirInfo.Parent == null;
    DirectoryInfo di = isRoot ? new DirectoryInfo(@"\\?\" + context.RepositoryPath.TrimEnd(System.IO.Path.DirectorySeparatorChar)) : dirInfo;
    // delete hidden folder 
    string folderPath = System.IO.Path.Combine(di.FullName, name);
    if (Directory.Exists(folderPath) && new DirectoryInfo(folderPath).Attributes.HasFlag(FileAttributes.Hidden))
    {
        Directory.Delete(folderPath, true);
    }
    di.CreateSubdirectory(name);
}
See Also