I have a method that tries to execute an event / method (Download_Click), although for some reason I get:
The name ‘sender’ does not exist in the current context
The name ‘e’ does not exist in the current context
The button definitely exists, although for some reason won’t work in my code below:
private void checkver()
{
FileInfo sourceFile = new FileInfo("download.zip");
if (sourceFile.Exists)
{
var request = (HttpWebRequest)WebRequest.Create(@"http://www.google.com/download.zip");
request.Method = "HEAD";
var response = (HttpWebResponse)request.GetResponse();
if (response.LastModified > sourceFile.LastWriteTime)
{
MessageBox.Show("File outdated");
Download_Click(sender, e);
// use response.GetStream() to download the file.
}
else
{
MessageBox.Show("File in date");
}
}
}
Adam Robinson‘s answer is the right one – but if you really really really want to do that call (no, please don’t) (I mean, REALLY, DON’T) you can use