WebClient.DownloadFileCompleted 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
비동기 파일 다운로드 작업이 완료되면 발생합니다.
public:
event System::ComponentModel::AsyncCompletedEventHandler ^ DownloadFileCompleted;
public event System.ComponentModel.AsyncCompletedEventHandler? DownloadFileCompleted;
public event System.ComponentModel.AsyncCompletedEventHandler DownloadFileCompleted;
member this.DownloadFileCompleted : System.ComponentModel.AsyncCompletedEventHandler
Public Custom Event DownloadFileCompleted As AsyncCompletedEventHandler
Public Event DownloadFileCompleted As AsyncCompletedEventHandler
이벤트 유형
예제
다음 코드 예제에 대 한 이벤트 처리기를 설정 하는 방법을 보여 줍니다는 DownloadFileCompleted
이벤트입니다.
// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt");
void DownLoadFileInBackground2( String^ address )
{
WebClient^ client = gcnew WebClient;
Uri ^uri = gcnew Uri(address);
// Call DownloadFileCallback2 when the download completes.
client->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallback2 );
// Specify a progress notification handler here...
client->DownloadFileAsync( uri, "serverdata.txt" );
}
void DownloadFileCallback2( Object^ /*sender*/, System::ComponentModel::AsyncCompletedEventArgs^ e )
{
if ( e->Cancelled )
{
Console::WriteLine( "File download cancelled." );
}
if ( e->Error != nullptr )
{
Console::WriteLine( e->Error->ToString() );
}
}
// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt");
public static void DownLoadFileInBackground2(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
// Call DownloadFileCallback2 when the download completes.
client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCallback2);
// Specify a progress notification handler here ...
client.DownloadFileAsync(uri, "serverdata.txt");
}
private static void DownloadFileCallback2(object sender, AsyncCompletedEventArgs e)
{
if (e.Cancelled)
{
Console.WriteLine("File download cancelled.");
}
if (e.Error != null)
{
Console.WriteLine(e.Error.ToString());
}
}
' Sample call : DownLoadFileInBackground2 ("http:' www.contoso.com/logs/January.txt")
Public Shared Sub DownLoadFileInBackground2(address As String)
Dim client As WebClient = New WebClient()
' Call DownloadFileCallback2 when the download completes.
AddHandler client.DownloadFileCompleted, AddressOf DownloadFileCallback2
' Specify a progress notification handler here...
Dim uri as Uri = New Uri(address)
client.DownloadFileAsync(uri, "serverdata.txt")
End Sub
Private Shared Sub DownloadFileCallback2(sender As Object, e As AsyncCompletedEventArgs)
If e.Cancelled = True Then
Console.WriteLine("File download cancelled.")
End If
If Not e.Error Is Nothing Then
Console.WriteLine(e.Error.ToString())
End If
End Sub
설명
이 이벤트는 비동기 파일 다운로드 작업이 완료될 때마다 발생합니다. 비동기 파일 다운로드는 메서드를 호출 DownloadFileAsync 하여 시작됩니다.
는 AsyncCompletedEventHandler 이 이벤트의 대리자입니다. 클래스는 AsyncCompletedEventArgs 이벤트 데이터와 함께 이벤트 처리기를 제공합니다.
이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기