This is the first one:
Expand|Select|Wrap|Line Numbers
- Client.DownloadFileAsync(myUri,Path.Combine( temp_dir + temp_file));
Expand|Select|Wrap|Line Numbers
- Client.DownloadFileAsync(mySatelliteUri, Path.Combine(temp_dir + satellite_file_name));
Expand|Select|Wrap|Line Numbers
- Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
Expand|Select|Wrap|Line Numbers
- 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 downloadfilecompleted eventargs event.
Since both files are downloading to the same downloadfilecompleted 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 downloadfilecompleted 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 downloadfilecompleted event:
Expand|Select|Wrap|Line Numbers
- 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 downloadfilecompleted event im taking care of the radar images.
Now i want to make there in the downloadfilecompleted code to take care for the satellite images.
In other words in the downloadfilecompleted event i want to make once a cheking for:
Expand|Select|Wrap|Line Numbers
- Client.DownloadFileAsync(myUri,Path.Combine( temp_dir + temp_file));
Expand|Select|Wrap|Line Numbers
- 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.