I am having an error in my program when trying to download files from a remote server, I am using the System.Net Lib and it is having an issue converting to it.
I am getting the error Message
Cannot implicitly convert type
‘System.ComponentModel.AsyncCompletedEventHandler’ to
System.Net.DownloadProgressChangedEventHandler’
on the last line in the code block
AsyncCompletedEventHandler(client_DownloadFileCompleted);
Error Line ^
Form.cs V
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace Buildcraft_Installer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnStartDownload_Click(object sender, EventArgs e)
{
prgDownload.Visible = true;
WebClient client = new WebClient();
client.DownloadProgressChanged += new
DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadProgressChanged += new
AsyncCompletedEventHandler(client_DownloadFileCompleted);
I would be very grateful if anyone had a way to resolve this or a workaround to get the same result, thanks 🙂
You probably meant to write
client.DownloadFileCompletedon your last line.You currently have two calls to
DownloadProgressChanged, one with a matching delegate type (DownloadProgressChangedEventHandler), one with the wrong one (AsyncCompletedEventHandler).