/// <summary> /// Convert input file to output file. /// </summary> /// <param name="inputPath">Path of input file</param> /// <param name="outputPath">Path of output file</param> /// <param name="filename">file name</param> /// <param name="src">source string</param> /// <param name="dst">destination string</param> private static void RouteConvertTool(string inputPath, string outputPath, string filename, string src, string dst) { var cnt = 0; var line = string.Empty; var inputfilename = inputPath + filename; var outputfilename = My.CheckPath(outputPath, filename); using (TextReader reader = new StreamReader(inputfilename)) { using (TextWriter writer = new StreamWriter(outputfilename)) { while ((line = reader.ReadLine()) != null) { var output = line.Replace(src, dst); writer.WriteLine(output); if (line != output) { ++cnt; } } } } Console.ForegroundColor = (cnt == 0) ? ConsoleColor.Red : ConsoleColor.White; Console.WriteLine($"Converting to: {outputfilename}."); totalCnt += (cnt > 0) ? 1 : 0; }
private void NewToolStripMenuItem_Click(object sender, EventArgs e) { if (!AskToSaveModifiedRoute()) { btnClear_Click(sender, e); Overlay.Route.FileName = My.CheckPath(Settings.RoutePath, "Route66.xml"); this.Text = Title + Overlay.Route; } }
private void cmbMessage_Validated(object sender, EventArgs e) { if (Settings.SpeechSyntesizer) { var wavFile = My.CheckPath(Settings.RoutePath, "VoiceFiles", My.ValidateFilename(cmbMessage.Text) + ".wav"); My.Log($"Save speechfile {wavFile}."); Speech.SaveWav(cmbMessage.Text, wavFile); } cmbMessage_SelectedIndexChanged(sender, null); }
/// <summary> /// Limit maximum logfile size to 1 Mb. /// </summary> private string InitializeLogfile() { try { var IsRemote = My.Drive.ToUpper() != "C:\\"; var fileName = (IsRemote) ? My.LogFile : My.CheckPath(Settings.RoutePath, "log", My.LogFile); if (File.Exists(fileName)) { var fi = new FileInfo(fileName); if (fi.Length > 1000000) { File.Delete(fileName); } } return(fileName); } catch (Exception ee) { My.Log($"InitializeLogfile {ee.Message + ee.InnerException}"); } return(""); }