Update TemporaryFile to be stored in .../Kelwin/
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user