diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs b/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs
index 4e7a1993..2035f17d 100644
--- a/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs
+++ b/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs
@@ -517,13 +517,19 @@ Please check the log folder if the stats scrolled offscreen", false);
/// Dictionary of file types to StreamWriters
private static Dictionary OutputStatsGetOutputWriters(StatDatFormat statDatFormat, string reportName, string outDir)
{
- Dictionary output = new Dictionary();
+ Dictionary output = new Dictionary();
+
+ // First try to create the output directory if we need to
+ if (!Directory.Exists(outDir))
+ {
+ Directory.CreateDirectory(outDir));
+ }
// For each output format, get the appropriate stream writer
if ((statDatFormat & StatDatFormat.None) != 0)
{
reportName = Style.GetFileNameWithoutExtension(reportName) + ".txt";
- Path.Combine(outDir, reportName);
+ reportName = Path.Combine(outDir, reportName);
// Create the StreamWriter for this file
output.Add(StatDatFormat.None, new StreamWriter(FileTools.TryCreate(reportName)));
@@ -531,7 +537,7 @@ Please check the log folder if the stats scrolled offscreen", false);
if ((statDatFormat & StatDatFormat.CSV) != 0)
{
reportName = Style.GetFileNameWithoutExtension(reportName) + ".csv";
- Path.Combine(outDir, reportName);
+ reportName = Path.Combine(outDir, reportName);
// Create the StreamWriter for this file
output.Add(StatDatFormat.CSV, new StreamWriter(FileTools.TryCreate(reportName)));
@@ -539,7 +545,7 @@ Please check the log folder if the stats scrolled offscreen", false);
if ((statDatFormat & StatDatFormat.HTML) != 0)
{
reportName = Style.GetFileNameWithoutExtension(reportName) + ".html";
- Path.Combine(outDir, reportName);
+ reportName = Path.Combine(outDir, reportName);
// Create the StreamWriter for this file
output.Add(StatDatFormat.HTML, new StreamWriter(FileTools.TryCreate(reportName)));
@@ -547,7 +553,7 @@ Please check the log folder if the stats scrolled offscreen", false);
if ((statDatFormat & StatDatFormat.TSV) != 0)
{
reportName = Style.GetFileNameWithoutExtension(reportName) + ".csv";
- Path.Combine(outDir, reportName);
+ reportName = Path.Combine(outDir, reportName);
// Create the StreamWriter for this file
output.Add(StatDatFormat.TSV, new StreamWriter(FileTools.TryCreate(reportName)));