diff --git a/WGneu/App.xaml.cs b/WGneu/App.xaml.cs index 72520b5..36e8165 100644 --- a/WGneu/App.xaml.cs +++ b/WGneu/App.xaml.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.IO; namespace WGneu { public partial class App : Application { @@ -15,6 +16,7 @@ namespace WGneu { public App() : base() { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "Kelwin")); MainDispatcher = Dispatcher; } diff --git a/WGneu/Documents/Document.cshtml.cs b/WGneu/Documents/Document.cshtml.cs index eacb2d6..8863d38 100644 --- a/WGneu/Documents/Document.cshtml.cs +++ b/WGneu/Documents/Document.cshtml.cs @@ -50,8 +50,8 @@ namespace WGneu.Documents { } public async Task Generate() { - var pdf = new Utils.TemporaryFile(".pdf"); - using (var tmpHtml = new Utils.TemporaryFile(".html")) { + var pdf = new Utils.TemporaryFile("pdf"); + using (var tmpHtml = new Utils.TemporaryFile("html")) { await File.WriteAllTextAsync(tmpHtml.FilePath, await Render()); await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath); } diff --git a/WGneu/Utils.cs b/WGneu/Utils.cs index b214b23..78ed22a 100644 --- a/WGneu/Utils.cs +++ b/WGneu/Utils.cs @@ -60,12 +60,12 @@ namespace WGneu { private int Usages = 0; public string FilePath { get; private set; } - public TemporaryFile() : this("") {} + public TemporaryFile() : this(null) {} - public TemporaryFile(string ext) : this(Path.GetTempPath(), ext) {} + public TemporaryFile(string? ext) : this(Path.Combine(Path.GetTempPath(), "Kelwin"), ext) {} - public TemporaryFile(string dir, string ext) { - FilePath = Path.Combine(dir, Path.GetRandomFileName() + ext); + public TemporaryFile(string dir, string? ext) { + FilePath = Path.Combine(dir, Path.GetRandomFileName().Replace(".", "") + (ext != null ? $".{ext}" : "")); Usages++; Create(); }