简体   繁体   中英

How to obtain downloaded file's name on VB.NET

I have async threads downloading with webClient.DownloadFileAsync() and handled downloadCompleted event.

I want to know what is the file is just downloaded when the event is raising up. I tried with the sender of the event, but webClient doesn't have any method for this.

It's a desktop app for Windows, playing videos one after another. The dowloaded file's name is important because video's weight may be large and when one is downloaded the program must displayed it.

Right now the app, until all the files are downloaded, doesn't add the videos to the playlist because I don't know what the video downloaded is called. Videos are downloaded from a server.

     Private Sub myWebClient_DownloadFileCompleted(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs) Handles myWebClient.DownloadFileCompleted
    Dim mySender As WebClient = CType(sender, WebClient)

   videoName = mysender.  'Here is where I try to obtain downloaded file's name
    Dim VideoFile1 As WMPLib.IWMPMedia3 = AxWindowsMediaPlayer1.newMedia(path & videoName)
    Playlist.appendItem(VideoFile1)

End Sub

当您调用DownloadFileAsync方法时,以filename为参数进行调用,如.DownloadFileAsync(url, filename, filename)则可以在myWebClient_DownloadFileCompleted方法中以Dim filename As String= CType(e.UserState, String)myWebClient_DownloadFileCompleted获取文件名

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM