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.

 


What WebDAV software would you like to have?

Selected Customers:
Country: Norway
DnB NOR Group
Country: Finland
Bank of Finland
Country: United Kingdom
Bechtle Direct
Country: Sweden
BT Industries
Country: USA
California Chamber of Commerce
Country: Denmark
Danfoss Group
Country: Denmark
DFDS
Country: USA
Fluke Networks
Country: USA
HNI Corporation
Country: USA
IHS Inc
Country: USA
LandAmerica Financial Group
Country: Canada
Laurentian University
Country: USA
Microsoft
Country: Israel
RADVISION
Country: Ukraine
Raiffeisen Bank
Country: Netherlands
Sanoma Uitgevers
Country: USA
Siemens
Country: Australia
WorkCover NSW
Country: Ukraine
OTP Bank
Country: USA
Intel Corporation
Country: Austria
Austrian Federal Railways
Home .NET Server Java Server .NET Client AJAX Client AJAX Browser Map Drive Pricing Contacts

Updated: Sunday, October 26, 2008