1
我正在使用以下來遍歷日期範圍並從文本文件導入到數據庫中。我想知道如何告訴代碼如果文件不會退出,則繼續下一個文件?如果循環失敗則繼續
for (DateTime date = last_date; date.Date <= DateTime.Today; date = date.AddDays(1))
{
string file_name = "H" + date.ToString("yyyy-MM-dd") + ".TXT";
MySqlBulkLoader bl = new MySqlBulkLoader(sql_connection);
bl.TableName = "processing_table";
bl.FieldTerminator = ",";
bl.LineTerminator = "\n";
bl.FileName = @"C:\Temp\Attendence\" + file_name;
bl.NumberOfLinesToSkip = 0;
int count = bl.Load();
string sql = "SELECT source, created_date, created_time, company, action, employee_number, employee_name, outlet, field_1, field_2, field_3, field_4 FROM processing_table";
MySqlCommand cmd = new MySqlCommand(sql, sql_connection);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
SplashScreenManager.Default.SetWaitFormDescription(rdr[1] + " - " + rdr[2]);
}
rdr.Close();
}
umm ... if(File.Exists(...))'循環中的代碼?你有什麼嘗試? – BradleyDotNET 2014-09-19 21:30:38