/// <summary>
        /// Writes the input letterset to the file.
        /// </summary>
        /// <param name="rotorCount">The new number of rotors to save.</param>
        /// <param name="lettersetFile">The letterset file to save the letters to.</param>
        private void SaveToFile(LetterSet letterSet, string lettersetFile)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(File));
            string text = string.Join(Environment.NewLine, letterSet.Select(c => EscapeLetter(c)));

            System.IO.File.WriteAllText(lettersetFile, text);
        }
예제 #2
0
 /// <summary>
 /// Writes the input letterset to the file.
 /// </summary>
 /// <param name="letterSet">The letterset to save.</param>
 /// <param name="letterSetFile">The letterset file to save the letters to.</param>
 ///
 /// <exception cref="SaveFailedException">
 /// An error occurred while saving the file.
 /// </exception>
 public static void Write(LetterSet letterSet, string letterSetFile)
 {
     try {
         Directory.CreateDirectory(Path.GetDirectoryName(letterSetFile));
         string text = string.Join(Environment.NewLine, letterSet.Select(c => EscapeLetter(c)));
         File.WriteAllText(letterSetFile, text);
     }
     catch (Exception ex) {
         throw new SaveFailedException($"Failed to save the Letterset file!\n{ex.Message}");
     }
 }