logo
VitNX3 Documentation

# DataFromSites.DownloadFileWithSupportOfResume Method

Namespace: VitNX3.Functions.Web
Assembly: VitNX3 (in VitNX3.dll)
Downloads the file with support of download resume.
VB
C#
F#
C++
JScript
Copy

    public static void DownloadFileWithSupportOfResume(
       string sourceFileUrl,
       string targetFile
    )

    This language is not supported or no code example is available.

#### Parameters

sourceFileUrl
  string

The source file url.

targetFile
  string

The target file.

Source code
VB
C#
F#
C++
JScript
Copy

    public static void DownloadFileWithSupportOfResume(string sourceFileUrl,
         string targetFile)
     {
         long iFileSize = 0;
         int iBufferSize = 1024;
         iBufferSize *= 1000;
         long iExistLen = 0;
         FileStream saveFileStream;
         if (File.Exists(targetFile))
         {
             FileInfo fINfo = new FileInfo(targetFile);
             iExistLen = fINfo.Length;
         }
         if (iExistLen > 0)
             saveFileStream = new FileStream(targetFile,
               FileMode.Append,
               FileAccess.Write,
               FileShare.ReadWrite);
         else
             saveFileStream = new FileStream(targetFile,
               FileMode.Create,
               FileAccess.Write,
               FileShare.ReadWrite);
         HttpWebRequest hwRq;
         HttpWebResponse hwRes;
         hwRq = (HttpWebRequest)WebRequest.Create(sourceFileUrl);
         hwRq.AddRange((int)iExistLen);
         Stream smRespStream;
         hwRes = (HttpWebResponse)hwRq.GetResponse();
         smRespStream = hwRes.GetResponseStream();
         iFileSize = hwRes.ContentLength;
         int iByteSize;
         byte[] downBuffer = new byte[iBufferSize];
         while ((iByteSize = smRespStream.Read(downBuffer, 0, downBuffer.Length)) > 0)
             saveFileStream.Write(downBuffer, 0, iByteSize);
         saveFileStream.Close();
     }

    This language is not supported or no code example is available.

Applies to

#### .NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

#### .NET Core

Supported in: 5.0+, 6.0+
See Also
DataFromSites Class
VitNX3.Functions.Web Namespace