1 つのファイルをサーバーにアップロードする方法があります。現在、メソッドの悪いコーディングに加えて機能しています(タスクライブラリは初めてです)。
ファイルをサーバーにアップロードするコードは次のとおりです。
private async void UploadDocument()
{
var someTask = await Task.Run<bool>(() =>
{
// open input stream
using (System.IO.FileStream stream = new System.IO.FileStream(_cloudDocuments[0].FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
using (StreamWithProgress uploadStreamWithProgress = new StreamWithProgress(stream))
{
uploadStreamWithProgress.ProgressChanged += uploadStreamWithProgress_ProgressChanged;
// start service client
SiiaSoft.Data.FieTransferWCF ws = new Data.FieTransferWCF();
// upload file
ws.UploadFile(_cloudDocuments[0].FileName, (long)_cloudDocuments[0].Size, uploadStreamWithProgress);
// close service client
ws.Close();
}
}
return true;
});
}
次に、複数のファイルをドラッグアンドドロップできるListBoxがあるので、ListBoxファイル内でFOR LOOPを実行してから呼び出しますUploadDocument();
が、最初にlistBoxに最初のファイルをアップロードし、完了したら2番目のファイルを続行しますファイルなど...
それを行う最善の方法の手がかりはありますか?
どうもありがとう。