none
background Intelligent transfer services. File Upload / Download RRS feed

  • Question

  • I am using background Intelligent transfer services(BITS) for file transfer.
    For this i am using Microsoft.Net.BITS.dll
    when i upload a file i have used "BackgroundCopyJobType.Upload" job type. the file gets uploaded.
    for download i have used "BackgroundCopyJobType.Download" the file gets downloaded but it justs shows the tmp file and not the actual file.

    What happens is,For example I select 125MB.zip file for download, it completes the download (i.e it show 100% complete). But when you check that file in the desired location the file is not  there. Only the tmp will be seen. Now suppose you add another file say 1Gb.zip to download, the moment you click download it shows the 1st file  i.e it show 125MB.zip file and a new tmp file is generated for 1Gb.zip file. Even if the download of 1Gb.zip is completed it show the tmp file until and unless you add a new file for download.

    Can anyone help me to resolve this issue. Its Urgent




    Wednesday, October 1, 2008 8:02 AM

Answers

  • You can only call Complete() when the state is Transferred, not Transferring.
    Hans Passant.
    • Marked as answer by Shilpa_Katke Saturday, October 4, 2008 6:35 AM
    Friday, October 3, 2008 9:41 AM
    Moderator

All replies

  • Hmm, I didn't know BITS was supported by the .NET framework.  Somebody forgot to tell MSDN as well.  Generically, you'll see this kind of behavior when you didn't call IBackgroundCopyJob.Complete().  BITS requires you to explicitly confirm that the transfer is completed.  It's got various ways to tell you.  This is true for uploads too, although it looks better because the receiving end probably calls Complete() properly.
    Hans Passant.
    Wednesday, October 1, 2008 12:13 PM
    Moderator
  • Thanks for the reply Hans :)
    As you said i added the following line when the transferring of job is complete


    foreach
    (Microsoft.Net.BITS.BackgroundCopyJob j in Microsoft.Net.BITS.BackgroundCopyManager.Jobs)
    {
        if (j.State == Microsoft.Net.BITS.BackgroundCopyJobState.Transferring)
        {
            foreach (Microsoft.Net.BITS.BackgroundCopyFileInfo f in j.Files)
            {
                float PercentCom = f.PercentComplete;
                do
                
    {    
     
                        if (PercentCom == 100)
                        {
    // time when Upload/Download file is finished successfully
                            j.Complete();
                            // Break the do while loop
                            PercentCom = 101;
                        }
                        else
                        {
                            Console.WriteLine("Transfering file '"+ f.PercentComplete +"'% complete.");
                            PercentCom = f.PercentComplete;
                        }
                }
    while (PercentCom <= 100);
            }
        }
    }

    But still i am getting the same thing. Only the tmp file is seen.

    Friday, October 3, 2008 4:47 AM
  • You can only call Complete() when the state is Transferred, not Transferring.
    Hans Passant.
    • Marked as answer by Shilpa_Katke Saturday, October 4, 2008 6:35 AM
    Friday, October 3, 2008 9:41 AM
    Moderator
  • Thanks a ton Hans, that worked :)
    Saturday, October 4, 2008 6:35 AM
  • Hi,

    I   trying to get Microsoft.Net.BITS or System.Net.BITS dll , from where can i get this dll. Kindly help me on this.


    Friday, April 26, 2013 5:51 AM