简体   繁体   English

NET中如何使用Background Transfer Service上传文件

[英]How upload file using Background Transfer Service in .Net

I want to upload files to IIS server using BITS extension. 我想使用BITS扩展名将文件上传到IIS服务器。 I have a powershell script that uploads successfully: 我有一个成功上传的Powershell脚本:

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

Where 'filelist.txt' is CSV file containing following content: 其中“ filelist.txt”是包含以下内容的CSV文件:

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

To upload via C# I am using following snippet: 要通过C#上传,我正在使用以下代码段:

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. 我很高兴地说,关于如何从.NET调用BITS有一些全新的文档可能会有所帮助。 That documentation describes how to use BITS using Reference DLLs. 该文档描述了如何通过参考DLL使用BITS。

Which .NET library are you using in your code? 您在代码中使用哪个.NET库? 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. 例如,您创建了一个名为“ UploadJob”的变量,名称为“ Download job”,但是当您添加文件时,该变量就位于一个名为DownloadJob的变量中。 Can you provide a larger code sample? 您可以提供更大的代码示例吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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