In my code in two places im using webclient to download images from two other sites every 5 minutes.
This is the first one:
And this is the second one:
Now im registering once to downloadfilecom pleted event in my constructor:
Now in the downloadfilecom pleted eventArgs:
Im doing some checkings and test on the downloaded files.
But since im downloading files from another sites even if t hey are both images but they have another content i want to seperate the actions im doing on the files inside the downloadfilecom pleted eventargs event.
Since both files are downloading to the same downloadfilecom pleted event i need to make somehow that when one of the files is downloaded so only some of the code in the completed event will take care of it and if the other file is downloaded then it will take care of it.
I mean i have one downloadfilecom pleted event and both files are getting to there after downloaded i mean getting to this event how can i seperate the tests and actions to each file?
This is the code of the downloadfilecom pleted event:
Now i need in there to make another code same thing but instead of radar files to take care of satellite files. since the radar files are downloading to a specific directory and the satellite images are downloading to another directory.
But if ill put there the same code wich i have allready in my general code it will be a mess since both files are getting to the same completed event and how it will know to wich code to go and make the tests?
In this example of downloadfilecom pleted event im taking care of the radar images.
Now i want to make there in the downloadfilecom pleted code to take care for the satellite images.
In other words in the downloadfilecom pleted event i want to make once a cheking for:
And if the other file is downloaded so the completed event will take care for the
If someone please can show me a sample how to do it and explain also how to do it cuz i cant figure it out for long time now.
And for now the files are getting to the same event and thats making problems.
Thanks for helping.
This is the first one:
Code:
Client.DownloadFileAsync(myUri,Path.Combine( temp_dir + temp_file));
Code:
Client.DownloadFileAsync(mySatelliteUri, Path.Combine(temp_dir + satellite_file_name));
Code:
Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
Code:
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { }
But since im downloading files from another sites even if t hey are both images but they have another content i want to seperate the actions im doing on the files inside the downloadfilecom pleted eventargs event.
Since both files are downloading to the same downloadfilecom pleted event i need to make somehow that when one of the files is downloaded so only some of the code in the completed event will take care of it and if the other file is downloaded then it will take care of it.
I mean i have one downloadfilecom pleted event and both files are getting to there after downloaded i mean getting to this event how can i seperate the tests and actions to each file?
This is the code of the downloadfilecom pleted event:
Code:
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Error != null) { pictureBox2.Load(@"d:\Weather_Michmoret.bmp"); return; } if (!e.Cancelled) { string Next_File; bool file_compare; int i; bool bad_file; file_array_dl = Directory.GetFiles(sf, "radar*.jpg"); if (file_array_dl.Length == 0) { File.Copy(temp_dir + temp_file, sf + @"\radar001.jpg"); realtime_write_to_Log("Last Downloaded file is :" + sf + @"\radar001.jpg"); } else { File.Copy(temp_dir + temp_file, bad_file_test_dir + testing_file); bad_file = Bad_File_Testing(bad_file_test_dir + testing_file); if (bad_file == false) { File.Delete(bad_file_test_dir + testing_file); return; } else { File.Delete(bad_file_test_dir + testing_file); i = last_image_file(); last_file = sf + @"\radar" + i.ToString("D3") + ".jpg"; File.Copy(last_file, bad_file_test_dir + testing_file); bad_file = Bad_File_Testing(bad_file_test_dir + testing_file); if (bad_file == true) { File.Delete(bad_file_test_dir + testing_file); if (File.Exists(last_file)) { file_compare = File_Utility.File_Comparison(temp_dir + temp_file, last_file); if (file_compare == true) { return; } i = last_image_file() + 1; Next_File = sf + @"\radar" + i.ToString("D3") + ".jpg"; File.Copy(temp_dir + temp_file, Next_File); realtime_write_to_Log("Last Downloaded file is :" + Next_File); pictureBox1.Load(Next_File); // parameter is not valid כי הוא מנסה להעלות פה תמונה דפוקה שמשום מה הגיעה לספרייה של המכ"ם במקום להימחק. התמונה הדפוקה ירדה גם לספרייה הזמנית. לבדוק מדוע היא לא טופלה. button1.Enabled = true; } } else { File.Delete(last_file); File.Delete(bad_file_test_dir + testing_file); } } } } }
But if ill put there the same code wich i have allready in my general code it will be a mess since both files are getting to the same completed event and how it will know to wich code to go and make the tests?
In this example of downloadfilecom pleted event im taking care of the radar images.
Now i want to make there in the downloadfilecom pleted code to take care for the satellite images.
In other words in the downloadfilecom pleted event i want to make once a cheking for:
Code:
Client.DownloadFileAsync(myUri,Path.Combine( temp_dir + temp_file));
Code:
Client.DownloadFileAsync(mySatelliteUri, Path.Combine(temp_dir + satellite_file_name));
And for now the files are getting to the same event and thats making problems.
Thanks for helping.
Comment