ערכתי לאחרונה בתאריך 26.05.10 בשעה 12:21 בברכה, Nexus
אני משתמש על אותו הרעיון ממש זהה על קובץ אחר ואין שום בעיה כשהעתקתי את הקטע של הקוד רק שיניתי את שם הפונקציה ושם הקבצים בתוכנה פתאום הוא זורק לי שגיאה.
אז דבר ראשון אני מוריד קובץ:
Client.DownloadFile(satellite_address, satellite_dir + satellite_file_name);
|
בדקתי את זה והקובץ תקין ואין לי בעיה להשתמש בו בקוד שלי הקובץ יורד ב constructor.
אחרי זה פעם ראשונה שאני משתמש בקובץ זה מעלה אותו ל picturebox2 במקום של form1_load ואין בעיה עם זה.
המקום השני שאני משתמש בקובץ הוא פה בפוקנציה הזו:
private void timer5_Tick(object sender, EventArgs e) { string Next_File; bool file_compare; int i; bool bad_file; file_array_dl = Directory.GetFiles(satellite_dir, "satellite*.jpg"); if (file_array_dl.Length == 0) { label6.Text = "Directory is empty therefore Showing sample image"; pictureBox1.Load(@"d:\Weather_Michmoret.bmp"); realtime_write_to_Log("Last Downloaded file is :" + satellite_dir + satellite_file_name + @"\satellite.jpg"); } else { //i = file_array_dl.Length; // Need to change to last_file_image() i = last_satellite_file(); last_file = satellite_dir + @"\satellite" + 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(satellite_dir + satellite_file_name, last_file); if (file_compare == true) { return; } //i = 0; //i = file_array_dl.Length + 1; // Need to change to last_file_image() i = last_satellite_file() + 1; Next_File = satellite_dir + @"\satellite" + i.ToString("D3") + ".jpg"; File.Copy(satellite_dir + satellite_file_name, Next_File); realtime_write_to_Log("Last Downloaded file is :" + Next_File); pictureBox2.Load(Next_File); } else { File.Delete(last_file); File.Delete(bad_file_test_dir + testing_file); } } }
|
וגם פה אין בעיה עד שהוא מנסה לקורא לפונקציה:
i = last_satellite_file();
|
אז הוא הולך לפונקציה הזו ושם זורק לי את השגיאה זו הפונקציה:
private int last_satellite_file() { int max_image_files_number = 0; string files_names = Directory.GetFiles(satellite_dir, "satellite*.jpg"); for (int i = 0; i < files_names.Length; i++) { string current_name = files_names; int start_index = current_name.LastIndexOf("satellite") + 9; // we get the starting index of radar and then add the length of 'radar', which is 5 int last_index = current_name.LastIndexOf('.'); string image_file_number = current_name.Substring(start_index, last_index - start_index); int image_file_number_converted = Convert.ToInt32(image_file_number); if (image_file_number_converted > max_image_files_number) { max_image_files_number = image_file_number_converted; } } return max_image_files_number; }
|
והשגיאה שהוא נותן לי זה :
Formatexception was unhandled. Input string was not in a correct format. Make sure your method arguments are in the right format. When converting a string to DateTime, Parse the string to take the date before putting each variable into the DateTime Object.
|
לא מבין מה הבעיה כי במקום אחר בקוד שלי אני משתמש בדיוק זהה באותו הדבר רק שמות שונים לקבצים ולמשתנים למעשה זה אותם משתנים כי הם בתוך הפונקציה לא בראש הקלאס אז אין התנגשות והשימוש בפונקציה הראשונה הזהה הוא שונה במקום אחר ואין שום בעיה. אני לא מבין למה פה יש בעיה.
תודה על העזרה.