Home
english
Home
.NET Server
Java Server
.NET Client
AJAX Client
AJAX Browser
Map Drive
Pricing
Contacts
info@ithit.com



Downloading Files from WebDAV Server Using .NET API, C#

Using the API you can download either the entire file or request only a part of a file. To download the entire file and save it to local file system:

string license = "<?xml version='1.0' encoding='u...

WebDavSession session = new WebDavSession(license);

session.Credentials = new NetworkCredential("User1", "pwd");

IResource resource = session.OpenResource(new Uri("http://server:8080/Products/image.gif"));

resource.TimeOut = 36000000; // 10 hours

resource.Download("C:\\image.gif");

 

To download a file and save it directly to the database or any other storage:

IResource resource = session.OpenResource("http://server:8080/Products/image.gif");

resource.TimeOut = 36000000; // 10 hours

using (Stream webStream = resource.GetReadStream())

{

    int bufSize = 1048576; // 1Mb

    byte[] buffer = new byte[bufSize];

    int bytesRead = 0;

    using (FileStream fileStream = File.OpenWrite(resource.DisplayName))

    {

        while ((bytesRead = webStream.Read(buffer, 0, bufSize)) > 0)

            fileStream.Write(buffer, 0, bytesRead);

    }

}

The GetReadStream method provides overloaded instances to specify starting byte of the file to download and length. Using this method you can download a single file using several threads at a time or resume broken downloads.

 


Selected Customers:
Country: Norway
DnB NOR Group
Country: Finland
Bank of Finland
USA
Symantec
Country: Sweden
Toyota
Country: Denmark
Danfoss Group
Country: USA
Microsoft
Country: Ukraine
Raiffeisen Bank
Country: USA
Siemens
Country: Ukraine
OTP Bank
Country: USA
Intel Corporation
Country: Austria
Austrian Federal Railways
Country: Israel
Autodesk, Inc.
Country: USA
U.S. Customs and Border Protection Agency
Home .NET Server Java Server .NET Client AJAX Client AJAX Browser Map Drive Pricing Contacts

Updated: Sunday, October 26, 2008