public static void Handle_New_File() { string[] filePaths = Directory.GetFiles(CBS_Main.Get_Source_Data_Path(), "*.log*", SearchOption.AllDirectories); foreach (string Path in filePaths) { try { using (MyStreamReader = System.IO.File.OpenText(Path)) { if (MyStreamReader != null) { //// Pass in stream reader and initialise new //// EFD message. EFD_Msg EDF_MESSAGE = new EFD_Msg(MyStreamReader); MyStreamReader.Close(); MyStreamReader.Dispose(); try { //// Generate output Generate_Output.Generate(EDF_MESSAGE); } catch (Exception e1) { CBS_Main.WriteToLogFile("Error in Generate_Output.Generate " + e1.Message); } try { // Write data to the MySqlDatabase MySqlWriter.Write_One_Message(EDF_MESSAGE); } catch (Exception e2) { CBS_Main.WriteToLogFile("Error in MySqlWriter.Write_One_Message " + e2.Message); } // Let the status handler know that the // message has arrived... try { CBS_Main.Notify_EFD_Message_Recived(); } catch (Exception e3) { CBS_Main.WriteToLogFile("Error in CBS_Main.Notify_EFD_Message_Recived " + e3.Message); } //// Once done with the file, //// lets delete it as we do not //// needed it any more try { System.IO.File.Delete(Path); } catch { CBS_Main.WriteToLogFile("Error in EFD_File_Handler, can't delete file " + Path); } break; } } } catch (Exception ex) { CBS_Main.WriteToLogFile("Exception EFD_Handler: " + ex.Message); } } }