2
같은 시간에 저장 :WPF는 파일을 다운로드 나는이 방법으로 파일을 다운로드
WebClient webClient = new WebClient();
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
webClient.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
webClient.DownloadDataAsync(new Uri(this.Url));
그리고 이것은 내가 디스크에 저장하는 방법입니다
void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
try
{
if (e.Result != null)
{
string VideoFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Playtube\\VideoCache\\" + this.id + ".wmv";
File.WriteAllBytes(VideoFile, e.Result);
isDownloading = false;
callbackFinish();
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
그리고 내가 원하는 파일을 다운로드하고 동시에 디스크에 저장하는 것이 가능한지 확인하고 파일을 저장하기 위해 다운로드가 완료 될 때까지 기다리지 마십시오.
'WebClient.DownloadFileAsync'라는 메서드가 있습니다. http://msdn.microsoft.com/en-US/library/ms144196(v=vs.90).aspx –