diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs
index 77776b06..f98e8ef8 100644
--- a/SabreHelper/Output.cs
+++ b/SabreHelper/Output.cs
@@ -119,5 +119,51 @@ namespace SabreTools.Helper
return true;
}
+
+ ///
+ /// Output a list of roms as a text file with an arbitrary prefix and postfix
+ ///
+ /// Name of the output file
+ /// List of RomData objects representing the roms to be output
+ /// Logger object for console and/or file output
+ /// True if only games are written to text file (default), false for files only
+ /// Arbitrary string to prefix each line
+ /// Arbitrary string to postfix each line
+ /// True if the file was written, false otherwise
+ public static bool WriteToText(string textfile, List roms, Logger logger, bool useGame = true, string prefix = "", string postfix = "")
+ {
+ logger.Log("Opening file for writing: " + textfile);
+
+ try
+ {
+ FileStream fs = File.Create(textfile);
+ StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
+
+ string lastgame = "";
+ foreach (RomData rom in roms)
+ {
+ if (useGame && rom.Game != lastgame)
+ {
+ sw.WriteLine(prefix + rom.Game + postfix);
+ lastgame = rom.Game;
+ }
+ else if (!useGame)
+ {
+ sw.WriteLine(prefix + rom.Name + postfix);
+ }
+ }
+
+ logger.Log("File written!" + Environment.NewLine);
+ sw.Close();
+ fs.Close();
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex.ToString());
+ return false;
+ }
+
+ return true;
+ }
}
}