Click or drag to resize

IFolderAsyncCreateFileAsync Method

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

Namespace:  ITHit.WebDAV.Server.Class1
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 9.1.5460-Beta
Syntax
Task<IFileAsync> CreateFileAsync(
	string name
)

Parameters

name
Type: SystemString
Name of the file to create.

Return Value

Type: TaskIFileAsync
New file 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.
Remarks
You must create a file in your repository during this call. After calling this method Engine calls [!:IContentAsync.WriteAsync].
Examples

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

public async Task<IFileAsync> CreateFileAsync(string name)
{
    await RequireHasTokenAsync();
    string fileName = System.IO.Path.Combine(fileSystemInfo.FullName, name);

    using (FileStream stream = new FileStream(fileName, FileMode.CreateNew))
    {
    }
    await context.socketService.NotifyRefreshAsync(Path);

    return (IFileAsync)await context.GetHierarchyItemAsync(Path + EncodeUtil.EncodeUrlPart(name));
}
See Also