Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Asynchronous downloading in C# [modified]

Asynchronous downloading in C# [modified]

Scheduled Pinned Locked Moved C#
csharphelptutorialquestioncareer
7 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    In C#, is there a simple way to resume an download over http, transparantly? For example, i call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Can any one help me??? Thanking U, Sunil G.

    modified on Saturday, May 1, 2010 4:38 AM

    A L RaviBeeR A 4 Replies Last reply
    0
    • L Lost User

      In C#, is there a simple way to resume an download over http, transparantly? For example, i call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Can any one help me??? Thanking U, Sunil G.

      modified on Saturday, May 1, 2010 4:38 AM

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Use the DownloadDataAsync method of the WebClient class to download files from a server.

      1 Reply Last reply
      0
      • L Lost User

        In C#, is there a simple way to resume an download over http, transparantly? For example, i call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Can any one help me??? Thanking U, Sunil G.

        modified on Saturday, May 1, 2010 4:38 AM

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Using WebClient you can download your file synchronously as well as asynchronously. Download File Synchronously

        using System.Net;

        WebClient webClient = new WebClient();
        webClient.DownloadFile("http://mysite.com/myfile.txt", @"c:\myfile.txt");

        Download File Asynchronously

        private void btnDownload_Click(object sender, EventArgs e)
        {
        WebClient webClient = new WebClient();
        webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
        webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
        webClient.DownloadFileAsync(new Uri("http://mysite.com/myfile.txt"), @"c:\myfile.txt");
        }

        private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
        progressBar.Value = e.ProgressPercentage;
        }

        private void Completed(object sender, AsyncCompletedEventArgs e)
        {
        MessageBox.Show("Download completed!");
        }

        Hope this will help!

        Jinal Desai - LIVE

        L 1 Reply Last reply
        0
        • L Lost User

          Using WebClient you can download your file synchronously as well as asynchronously. Download File Synchronously

          using System.Net;

          WebClient webClient = new WebClient();
          webClient.DownloadFile("http://mysite.com/myfile.txt", @"c:\myfile.txt");

          Download File Asynchronously

          private void btnDownload_Click(object sender, EventArgs e)
          {
          WebClient webClient = new WebClient();
          webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
          webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
          webClient.DownloadFileAsync(new Uri("http://mysite.com/myfile.txt"), @"c:\myfile.txt");
          }

          private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
          {
          progressBar.Value = e.ProgressPercentage;
          }

          private void Completed(object sender, AsyncCompletedEventArgs e)
          {
          MessageBox.Show("Download completed!");
          }

          Hope this will help!

          Jinal Desai - LIVE

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Madam I think u didnt get my point. For example, I call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Thanking You, Sunil G.

          L 1 Reply Last reply
          0
          • L Lost User

            In C#, is there a simple way to resume an download over http, transparantly? For example, i call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Can any one help me??? Thanking U, Sunil G.

            modified on Saturday, May 1, 2010 4:38 AM

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            The HttpWebRequest.AddRange()[^] method allows you to resume downloading from a specific point. /ravi

            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

            1 Reply Last reply
            0
            • L Lost User

              Madam I think u didnt get my point. For example, I call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Thanking You, Sunil G.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              So if you want resuming download then try following link. http://www.devx.com/dotnet/Article/22533[^]

              Jinal Desai - LIVE

              modified on Monday, May 3, 2010 5:37 AM

              1 Reply Last reply
              0
              • L Lost User

                In C#, is there a simple way to resume an download over http, transparantly? For example, i call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x. I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download. Can any one help me??? Thanking U, Sunil G.

                modified on Saturday, May 1, 2010 4:38 AM

                A Offline
                A Offline
                Abdul Rahman Hamidy
                wrote on last edited by
                #7

                I would recommend using Socket Class which provides you to resume, stop your downloading or Uploading.

                Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups