private void RerunOA3() { OA3_Action oaAction = new OA3_Action(); oaAction._OutputPath = _OutputPath; //oaAction._SelectedMotherBoardText = gbMB.Controls.OfType<RadioButton>().FirstOrDefault(r => r.Checked).Text; //oaAction.ClearKey(); if (!(Directory.Exists(_OutputPath + @"\Logs"))) { Directory.CreateDirectory(_OutputPath + @"\Logs"); } //TODO condense this 1/17/18 string[] filesArray = Directory.GetFiles(_OutputPath); List <string> fileNameArray = new List <string>(); foreach (string fullPath in filesArray) { string fileName = Path.GetFileName(fullPath); try { string from = System.IO.Path.Combine(fullPath); string to = System.IO.Path.Combine(_OutputPath + @"\Logs\" + fileName); File.Move(from, to); fileNameArray.Add(to); } catch (IOException ex) { Console.WriteLine(ex); } } foreach (string fullFilePath in fileNameArray) { string fileName = Path.GetFileName(fullFilePath); string directory = Path.GetDirectoryName(fullFilePath); string outputString = ""; string line; try { //After file move, append txt to already existing file if exists & rename .bin file with timestamp if (Path.GetFileName(fullFilePath) != "OA3.bin") { StreamReader reader1 = new StreamReader(fullFilePath); while ((line = reader1.ReadLine()) != null) { outputString += line + "\r\n"; } reader1.Close(); File.Delete(fullFilePath); string outputPath = directory + @"\" + fileName + "_OA3Log.txt"; Process_Action pa = new Process_Action(); pa.moveTextToFile(outputPath, outputString, "moveFiles"); } else { string newFileName = directory + @"\" + fileName + "_" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Year.ToString() + " Time_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Millisecond.ToString() + Path.GetExtension(fileName); File.Move(fullFilePath, newFileName); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } //oaAction.DefaultKey(); }