WebDavSession Constructor 

IT Hit WebDAV for .NET

Constructor for WebDAV session.

[Visual Basic]
Overloads Public Sub New( _
   ByVal license As String _
)
[C#]
public WebDavSession(
   string license
);

Parameters

license
License string.

Exceptions

Exception Type Condition
InvalidLicenseException The license is invalid.

Example

In the following example a file is uploaded to a WebDAV server.

                
string license = "<?xml version='1.0' encoding='utf...
WebDavSession session = new WebDavSession(license);
session.Credentials = new NetworkCredential("User1", "pwd");
IFolder folder = session.OpenFolder(new Uri("http://server:8080/Sales"));
FileInfo file = new FileInfo("C:\\Products.exe");

IResource resource = folder.CreateResource(file.Name);
resource.AllowWriteStreamBuffering = false;
resource.TimeOut = 36000000; // 10 hours
using (Stream webStream = resource.GetWriteStream("application/octet-stream", file.Length))
{
    int bufSize = 1048576; // 1Mb
    byte[] buffer = new byte[bufSize];
    int bytesRead = 0;

    using (FileStream fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
    {
        while ( (bytesRead = fileStream.Read(buffer, 0, bufSize))>0)
            webStream.Write(buffer, 0, bytesRead);
    }
}
                
            

See Also

WebDavSession Class | ITHit.WebDAV.Client Namespace