我在我的項目中使用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可以告訴我你可以做什麼。