私は自分のプロジェクトでBITSを使用しています-大きなサイズの送信ファイル用のバックグラウンドインテリジェント転送サービス。C# コードで SharpBITS.NET を使用する。サーバーからクライアントにファイルをアップロードしたい。私は今、側面に注意します。
- - - - - - -クライアント側 - - - - - - - -
static void Main(string[] args) {
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 take 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 アクションはファイルを受け取りません。クライアント側でファイルを受信する方法がわかりません。ご覧のとおり、受信ファイルに HttpPostedFileBase を使用しましたが、機能していません。
私のホスト サーバーは Windows サーバー 2008 r2 で、BITS に必要な手順を実行しました。詳細については、次のサイトを参照してくださいhttp://technet.microsoft.com/en-us/library/cc431377.aspx ---- Configuration Manager 2007 サイト システム用に Windows Server 2008 を構成する方法。
ホストサーバーでファイルを受信できるようにするにはどうすればよいかわかりません。できることを教えてください。