因此,我正在为我的程序创建一个下载程序,将文件下载到某个位置。但是,该文件未下载,并表示已完成。该文件大约有100MB以上,由于某种原因,它会在0.1秒内完成。有任何修复程序吗?
谢谢您<3!
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to download this scene?\nThis program is in BETA and MAY corrupt your old saves", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes) {
string templocation = Properties.Settings.Default.DownloadPath;
button1.Enabled = false;
button2.Enabled = false;
progressBar1.Visible = true;
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("http://hosting.wracked.nl/test.txt"), @templocation);
}
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Maximum = (int)e.TotalBytesToReceive / 100;
progressBar1.Value = (int)e.BytesReceived / 100;
}
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
button1.Enabled = true;
button2.Enabled = true;
progressBar1.Visible = false;
progressBar1.Value = 0;
MessageBox.Show("Download has been completed.\nPlease boot up your game and select save: 'Cheat1'", "Download Finished");
}
我也尝试过这种方法,而不是尝试使用这种方法:
client.DownloadFileAsync(new Uri("http://hosting.wracked.nl/test.txt"), @"C:\Users\kyano\Desktop\Programs\PW\Builds");
答案 0 :(得分:-1)
好的,我忘了添加:
@templocation + "filename.txt"
我的问题已解决:D