Hi,
I have a directory with a load of files in it, with each file named E_1, E_2, E_3 etc. There will never be more than 10 files.
Now, I want a user to click a button that will do the following to each file. So, do E_1, then delete it, do E_2 then delete it etc . . . .
//open the connection
conn.Open();
//delete any existing data
string sql_A1 = "TRUNCATE TEMP_TABLE;";
MySqlScript script_A1 = new MySqlScript(conn, sql_A1);
script_A1.Execute();
MySqlBulkLoader r = new MySqlBulkLoader(conn);
r.TableName = "TEMP_TABLE";
r.FieldTerminator = "\t";
r.LineTerminator = "\n";
r.FileName = FILE_TO_IMPORT; //this will be E_1, E_2, E_3 etc
r.NumberOfLinesToSkip = 0;
//load the file then delete the original
r.Load();
File.Delete(FILE_TO_IMPORT);
//run stored procedure to process the file in temp table
string rkl = "sp_process_temp_file"; //stored procedure name
MySqlCommand cmd_rkl = new MySqlCommand(rkl, conn);
cmd_rkl.CommandType = CommandType.StoredProcedure;
cmd_rkl.Connection = conn;
conn.Open();
cmd_rkl.ExecuteNonQuery();
conn.Close();
conn.Dispose();
Go back and do E_2 . . . . .
Is this possible? Note that all the above code works without issue. I just can't figure out how to loop it!
Thanks for any help received . . . .
I have a directory with a load of files in it, with each file named E_1, E_2, E_3 etc. There will never be more than 10 files.
Now, I want a user to click a button that will do the following to each file. So, do E_1, then delete it, do E_2 then delete it etc . . . .
//open the connection
conn.Open();
//delete any existing data
string sql_A1 = "TRUNCATE TEMP_TABLE;";
MySqlScript script_A1 = new MySqlScript(conn, sql_A1);
script_A1.Execute();
MySqlBulkLoader r = new MySqlBulkLoader(conn);
r.TableName = "TEMP_TABLE";
r.FieldTerminator = "\t";
r.LineTerminator = "\n";
r.FileName = FILE_TO_IMPORT; //this will be E_1, E_2, E_3 etc
r.NumberOfLinesToSkip = 0;
//load the file then delete the original
r.Load();
File.Delete(FILE_TO_IMPORT);
//run stored procedure to process the file in temp table
string rkl = "sp_process_temp_file"; //stored procedure name
MySqlCommand cmd_rkl = new MySqlCommand(rkl, conn);
cmd_rkl.CommandType = CommandType.StoredProcedure;
cmd_rkl.Connection = conn;
conn.Open();
cmd_rkl.ExecuteNonQuery();
conn.Close();
conn.Dispose();
Go back and do E_2 . . . . .
Is this possible? Note that all the above code works without issue. I just can't figure out how to loop it!
Thanks for any help received . . . .