简体   繁体   中英

How upload file using Background Transfer Service in .Net

I want to upload files to IIS server using BITS extension. I have a powershell script that uploads successfully:

Import-CSV filelist.txt | Start-BitsTransfer -TransferType Upload

Where 'filelist.txt' is CSV file containing following content:

Source, Destination iis-85.png, http://172.18.3.131/Uploads/iis-85.png

To upload via C# I am using following snippet:

private Manager manager =  new Manager();
private Job UploadJob = new Job("Download Job");
DownloadJob.Files.Add("http://172.18.3.134/uploads/iis-85.png","C:\Users\mohsin\Downloads\BITS\BITS\iis-85.png");
manager.Jobs.Add(DownloadJob);
DownloadJob.Resume();

But the job status always shows as queued.

I'm delighted to say that there's some brand-new documentation on how to call into BITS from .NET that may help. That documentation describes how to use BITS using Reference DLLs.

Which .NET library are you using in your code? Can you point me to its documentation?

My first thought from looking at the code snippet you provided is that you're mixing upload and download jobs. For example, you make a variable called UploadJob with a name of "Download job" but then when you add files, it's to a variable called DownloadJob. Can you provide a larger code sample?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM