У меня есть веб-клиент, который загружает видео с Facebook, и он у меня есть, чтобы пользователь мог отменить загрузку, но по какой-то странной причине, когда я вызываю свой метод отмены и пытаюсь загрузить другой файл, он ничего не делает. Это как метод отмены ломает веб-клиента, что я делаю не так? Это выдает ошибки, я полагаю, именно это приводит к его поломке ...
Я перепробовал все и до сих пор не могу понять, почему это происходит
Вот код для завершения загрузки данных.
Dim filedata As Byte() = e.Result
Dim datafile As String = save_path & "\" & facebook_id & ".mp4"
If cancelled = False Then
Notify.ShowBalloonTip(5000, "", "Video Successfully Downloaded!", ToolTipIcon.Info)
SMCT_Box.Text = ""
Else
Notify.ShowBalloonTip(5000, "", "Download Cancelled!", ToolTipIcon.Info)
End If
Using fileStream As FileStream = New FileStream(datafile, FileMode.Create)
fileStream.Write(filedata, 0, filedata.Length)
If File.Exists(datafile) Then
If cancelled = False Then
Tool_Tip.SetToolTip(Download_Button, "Download")
Download_Button.Text = "Download"
progress = 0
TaskbarManager.Instance.SetProgressValue(0, 100)
End If
End If
End Using
If cancelled = True Then
File.Delete(datafile)
cancelled = False
End If
If cancelled = False Then
If My.Settings.include_thumbnail = True Then
SaveThumbnail(thumbnail_link, thumbnail_id)
End If
If My.Settings.file_type = "mp3" Then
Dim message As String = "Converting Please Wait..."
MessageBox.Show(message, "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information)
Dim converter As New Process
converter.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
converter.StartInfo.CreateNoWindow = True
converter.StartInfo.FileName = app_path & "\Converter.exe"
converter.Start()
converter.WaitForExit()
If converter.HasExited = True Then
If My.Settings.open_after_download = True Then
Process.Start(save_path & "\" & facebook_id & ".mp3")
End If
If My.Settings.create_backup = True Then
My.Computer.FileSystem.CopyFile(save_path & "\" & facebook_id & ".mp3", app_path & "\Backups\" & facebook_id & ".mp3")
End If
End If
Else
If My.Settings.create_backup = True Then
My.Computer.FileSystem.CopyFile(save_path & "\" & facebook_id & ".mp4", app_path & "\Backups\" & facebook_id & ".mp4")
End If
End If
If My.Settings.open_after_download = True Then
Process.Start(save_path & "\" & facebook_id & ".mp4")
End If
End If
А вот код для метода отмены.
cancelled = True
facebook.CancelAsync()
facebook.Dispose()
DGV.Rows.Remove(DGV.SelectedRows(rows - 1))
rows -= 1
Tool_Tip.SetToolTip(Download_Button, "Download")
Download_Button.Text = "Download"
Thumbnail_Box.Image = Nothing
Thumbnail_Error_Label.Visible = True
progress = 0
TaskbarManager.Instance.SetProgressValue(0, 100)