リモートサーバーからエンドユーザーのコンピュータに5つのファイルをダウンロードするダウンローダを作成しようとしています。それに問題があります。 Function after Functionを使用することで、ダウンロードしますが、リモートファイルを読み込んでファイル名を取得し、配列に入れて一つの関数から一つずつダウンロードする必要があります。これはAsynchを使用してC#で書かれています。C#の配列を使用して複数のファイルをダウンロード
以下のマイコード。どんな助けもありがとう。
// Start Downloads
private void getPatch()
{
sw.Start();
string patchlist = Settings1.Default.patchlist;
label1.Text = "Downloading";
button2.Image = Properties.Resources.PlayButtonDisabled;
button4.Visible = false;
progressBar1.Visible = true;
Directory.CreateDirectory("WTF");
string[] files = new string[6];
files[0] = "libeay32.dll";
files[1] = "libmysql.dll";
files[2] = "libssl32.dll";
files[3] = "ssleay32.dll";
files[4] = "connection_patcher.exe";
files[5] = "Config.conf";
// Loop
foreach (var file in files)
{
var webClient = new WebClient();
webClient.DownloadFile(Settings1.Default.baseURL + file, file);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadStringCompleted += OnGetDownloadedStringCompleted;
}
}
問題は何ですか? – plast1k
リスト内に指定されたファイルはダウンロードされません。リストは各行のファイル名です。 – Keldo
サンプルには「リストに指定されたファイル」はありません( 'filelist'は単一文字です)。このコードから期待するものはあまり明確ではありません。この記事への回答は、提供されたコードのバグ、既存のソリューションのリンクhttp://stackoverflow.com/questions/22747645/download-multiple-files-in-parallel-using-c-sharpを参照してください。 –