Closed JeffSE97062 closed 3 years ago
Hi @JeffSE97062
Do you run the application with the same permission level as you have? Have you tried to run the app As Administrator?
I did try running as administrator and the file still wasn't removed.
Is the application a long running one like service or web server or it exists immediately after sending a file to a printer?
Exits immediately.
I see. File cleanup works by timer in background that why it doesn't work in your case. I'll publish an update early next week to support such cases. However files are deleted with a delay, so your application will await the end of the operation.
Thanks, Sergey
From: JeffSE97062 @.> Sent: Friday, September 24, 2021 7:52:32 PM To: svishnevsky/PDFtoPrinter @.> Cc: Sergey Vishnevskiy @.>; Comment @.> Subject: Re: [svishnevsky/PDFtoPrinter] CleanupFilesPrinter not removing files (#31)
Exits immediately.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/svishnevsky/PDFtoPrinter/issues/31#issuecomment-926850846, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AASEJU6SCSE6TMLNEVR2GQ3UDTCHBANCNFSM5ER3QSYQ.
Thanks! And thanks for putting this together.
Hi @JeffSE97062
Could you please try the 1.4.2 version and confirm that it solves your issue?
To turn on awaiting of file deletion you need to pass "true" to CleanupFilesPrinter constructor like below:
new CleanupFilesPrinter(new PDFtoPrinterPrinter(), true);
Hi @svishnevsky, same issue with the 1.4.2. The file is not removed.
Do you use a similar approach like below? `var wrapper = new CleanupFilesPrinter(new PDFtoPrinterPrinter(), true); await wrapper.Print(new PrintingOptions("Microsoft Print to PDF", "somefile.pdf"));'
Yes. ` class Program { static void Main(string[] args) { print(); }
static async void print()
{
// Delete after printing. Doesn't seem to work.
var wrapper = new CleanupFilesPrinter(new PDFtoPrinterPrinter(), true);
await wrapper
.Print(new PrintingOptions(
Properties.Settings.Default.Printer,
Properties.Settings.Default.FileToPrint)
);
}
}`
Thanks for sharing the code. You call the "print" method with no await, so your application exists before a Task is completed. Could you please try something like:
static sync Task Main(string[] args) { await print() }
or
static void Main(string[] args) { print(),GetAwaiter().GetResult(); }
That worked. Thanks.
CleanupFilesPrinter does not delete files after printing. The files are on my local PC and print successfully. I have administrative rights on the box.