我在我的项目中使用BITS - 后台智能传输服务发送文件的大小。在C#代码中使用SharpBITS.NET。 我想从服务器上传文件到客户端。我现在注意到双方。bits,sharpBits.net
-------------客户端---------------
静态无效的主要(字符串[]参数) {
string local = @"I:\a.mp3";
string destination = "http://192.168.56.128/BitsTest/Home/FileUpload";
string remoteFile = @destination;
string localFile = local;
if (!string.IsNullOrEmpty(localFile) && System.IO.File.Exists(localFile))
{
var bitsManager = new BitsManager();
var job = bitsManager.CreateJob("uploading file", JobType.Upload);
job.NotificationFlags = NotificationFlags.JobErrorOccured | NotificationFlags.JobModified |
NotificationFlags.JobTransferred;
job.AddFile(remoteFile, localFile);
job.Resume();
job.OnJobError += new EventHandler<JobErrorNotificationEventArgs>(job_OnJobError);
}
}
这是一个简单的控制台应用程序。本地路径我要发送的文件,目标 - 路径是接收者它是远程服务器。 当我运行程序job.Error需要mi follow ---“服务器的响应是无效的,服务器没有按照定义的协议,恢复工作,然后后台智能传输服务(BITS)将再次尝试。 - BG_E_HTTP_ERROR_200。-2145845048,0x801900C8“
对于客户端(接收器),我有以下代码:这是Mvs 3小项目,我只查看动作 我们的目的地路径。
public ActionResult FileUpload()
{
try
{
HttpPostedFileBase file = Request.Files[0];
file.SaveAs(System.IO.Path.Combine(Server.MapPath("/BitsTest/"), file.FileName));
}
catch
{ }
/*System.IO.File.Move(Server.MapPath("/BitsTest/bin/aa.png"), Server.MapPath("/BitsTest/Content/aa.png"));*/
}
但FileUpload行动thas not recevie文件。我不知道如何在客户端接收文件。 正如你所看到的,我使用HttpPostedFileBase作为recive文件,但那是行不通的。
我的主机服务器是Windows服务器2008 R2,我完成了BITS所需的步骤。有关更多信息,请访问以下站点http://technet.microsoft.com/en-us/library/cc431377.aspx ----如何为Configuration Manager 2007站点系统配置Windows Server 2008。
所以我不知道我在做什么,我可以接收文件在主机server.You可以告诉我你可以做什么。