public void addFilesFromList(string[] fileNames, string fileDirectory) { MySQLHandler handler = new MySQLHandler(); foreach (string fileName in fileNames) { try { FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None); BinaryFormatter bf = new BinaryFormatter(); RunLog log = (RunLog)bf.Deserialize(fs); handler.addRunLog(fileName, log); fs.Close(); } catch (Exception ex) { MessageBox.Show("Unable to open or read file " + fileName + " due to exception: " + ex.Message + ex.StackTrace); } } handler.CloseConnection(); }