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.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace WGneu {
|
namespace WGneu {
|
||||||
public partial class App : Application {
|
public partial class App : Application {
|
||||||
@ -15,6 +16,7 @@ namespace WGneu {
|
|||||||
|
|
||||||
public App() : base() {
|
public App() : base() {
|
||||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||||
|
Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "Kelwin"));
|
||||||
MainDispatcher = Dispatcher;
|
MainDispatcher = Dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ namespace WGneu.Documents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task Generate() {
|
public async Task Generate() {
|
||||||
var pdf = new Utils.TemporaryFile(".pdf");
|
var pdf = new Utils.TemporaryFile("pdf");
|
||||||
using (var tmpHtml = new Utils.TemporaryFile(".html")) {
|
using (var tmpHtml = new Utils.TemporaryFile("html")) {
|
||||||
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render());
|
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render());
|
||||||
await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath);
|
await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath);
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,12 @@ namespace WGneu {
|
|||||||
private int Usages = 0;
|
private int Usages = 0;
|
||||||
public string FilePath { get; private set; }
|
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) {
|
public TemporaryFile(string dir, string? ext) {
|
||||||
FilePath = Path.Combine(dir, Path.GetRandomFileName() + ext);
|
FilePath = Path.Combine(dir, Path.GetRandomFileName().Replace(".", "") + (ext != null ? $".{ext}" : ""));
|
||||||
Usages++;
|
Usages++;
|
||||||
Create();
|
Create();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user