IFolder.CreateResource Method 

IT Hit WebDAV for .NET

Creates new WebDAV resource with the specified name in this folder.

[Visual Basic]
Function CreateResource( _
   ByVal name As String, _
   ByVal content As Stream, _
   ByVal contentType As String _
) As WebDAVResponse
[C#]
WebDAVResponse CreateResource(
   string name,
   Stream content,
   string contentType
);

Parameters

name
Name of the resource to create.
content
Stream to read the content of the new resource from.
contentType
Indicates the media type of the new resource.

Return Value

Example

    public WebDAVResponse CreateResource(string name, Stream content, string contentType)
    {
        if(!ClientHasToken)
            return new LockedResponse();

        SqlConnection conn = new SqlConnection(connStr);
        SqlTransaction trans = null;
        conn.Open();
        try
        {
            trans = conn.BeginTransaction();
            Resource newResource = (Resource)CreateChild(trans, name, ItemType.Resource);
            newResource.WriteContent(trans, content, contentType);
            trans.Commit();
        }
        catch(Exception ex)
        {
            if(trans != null) trans.Rollback();
            throw;
        }
        finally
        {
            conn.Close();
        }

        return new CreatedResponse();
    }
 

See Also

IFolder Interface | ITHit.WebDAV.Server Namespace