This project is read-only.

Sample for Downloading a file form server

Sep 16, 2011 at 11:41 AM
Edited Sep 16, 2011 at 11:42 AM

Please share the implementation Sample for Downloading a file form server and handling on job completed event.

Sample Code i Used is

 BitsJob newJob = manager.CreateJob("Download from server", JobType.Download);
            newJob.AddFile("http://100.100.15.54/SampleForm/default.aspx", @"F:\Downloads\BITS\BITS\SampleDownloader\Downloads\a2.txt");
            manager.OnJobTransferred += new EventHandler<NotificationEventArgs>(manager_OnJobTransferred);
            newJob.OnJobTransferred+=new EventHandler<JobNotificationEventArgs>(newJob_OnJobTransferred);
            newJob.OnJobError += new EventHandler<JobErrorNotificationEventArgs>(newJob_OnJobError);
            newJob.Resume();

 

in the above code i am able to download but renaming is not happening to what i was specified "a2.txt"

it is downloading as .tmp extention.

 

Please do needful.

 

Regards

Anil

Sep 21, 2011 at 9:51 PM
Edited Sep 21, 2011 at 9:53 PM

I ran into the same problem. You need to call newJob.Complete() when the job actually completes in order to get the files into a usable state.  Something not documented in the wrapper API but available from the BITS documentation. :-/  (See here for details.)

Oct 6, 2011 at 6:42 AM
NormanHH wrote:

I ran into the same problem. You need to call newJob.Complete() when the job actually completes in order to get the files into a usable state.  Something not documented in the wrapper API but available from the BITS documentation. :-/  (See here for details.)


feel free to append to the SharpBITS documentation, but since the wrapper is basically just what he name suggests (a wrapper for the BITS api), all the original documentation still applies and there is not much value in replication

Oct 6, 2011 at 11:21 AM

It was just something that I found once I started getting into the BITS documentation, figured since someone else had the problem I would share my solution. No criticism intended, just clarification.

On Oct 6, 2011 1:42 AM, "xidar" <notifications@codeplex.com> wrote:
> From: xidar
>
> NormanHH wrote:
> I ran into the same problem. You need to call newJob.Complete() when the job actually completes in order to get the files into a usable state. Something not documented in the wrapper API but available from the BITS documentation. :-/ (See here for details.)
> feel free to append to the SharpBITS documentation, but since the wrapper is basically just what he name suggests (a wrapper for the BITS api), all the original documentation still applies and there is not much value in replication
>
>