UtilWebDownloadFileAsync(String, DirectoryInfo, DownloadProgressChangedEventHandler, AsyncCompletedEventHandler) Method
Asynchronously downloads a file to the specified directory.
The filename will be retrieved from url or from MIME types.
If filename cannot be retrieved, a random filename will be assigned to The output filepath.
Namespace: DevCase.Core.Networking.CommonAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static void DownloadFileAsync(
string url,
DirectoryInfo dir,
DownloadProgressChangedEventHandler callbackDownloadProgressChanged,
AsyncCompletedEventHandler callbackDownloadFileCompleted
)
Public Shared Sub DownloadFileAsync (
url As String,
dir As DirectoryInfo,
callbackDownloadProgressChanged As DownloadProgressChangedEventHandler,
callbackDownloadFileCompleted As AsyncCompletedEventHandler
)
Dim url As String
Dim dir As DirectoryInfo
Dim callbackDownloadProgressChanged As DownloadProgressChangedEventHandler
Dim callbackDownloadFileCompleted As AsyncCompletedEventHandler
UtilWeb.DownloadFileAsync(url, dir,
callbackDownloadProgressChanged,
callbackDownloadFileCompleted)
public:
static void DownloadFileAsync(
String^ url,
DirectoryInfo^ dir,
DownloadProgressChangedEventHandler^ callbackDownloadProgressChanged,
AsyncCompletedEventHandler^ callbackDownloadFileCompleted
)
static member DownloadFileAsync :
url : string *
dir : DirectoryInfo *
callbackDownloadProgressChanged : DownloadProgressChangedEventHandler *
callbackDownloadFileCompleted : AsyncCompletedEventHandler -> unit
No code example is currently available or this language may not be supported.
Parameters
- url String
-
The url to download.
- dir DirectoryInfo
-
The output directory.
- callbackDownloadProgressChanged DownloadProgressChangedEventHandler
-
A callback to report the download progress.
- callbackDownloadFileCompleted AsyncCompletedEventHandler
-
A callback to report the download completition.
This is a code example.
No code example is currently available or this language may not be supported.
Private Sub Test()
DownloadFile("http://download.thinkbroadband.com/5MB.zip", New DirectoryInfo("C:\"),
AddressOf DownloadProgressChanged,
AddressOf DownloadFileCompleted)
End Sub
Public Sub DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
Debug.WriteLine(e.BytesReceived)
End Sub
Public Sub DownloadFileCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
If (e.Error IsNot Nothing) Then
MessageBox.Show(e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show("Download completed.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.