This problem has been resolved. Thanks for all those who offered input. As it turns out, our new virus, malware, hijack prevention software, TrendMicro, was seeing a program on the computer acting 'suspiciously' when more than one file was being deleted in succession and was not only terminating the program but 'recovering' the deleted files. This was why deleting them one at a time was working but deleting two or more wouldn't. Our IT had just move us to a new cloud based version of TrendMicro. The solution was to provide an exclusion so that TrendMicro doesn't look at the activity of my program any longer. The fact is, I had just upgraded to the Delphi 10.2 just as the TrendMicro was also updated. My initial thought was that there was a problem between Delphi 10.2 and something in Windows 10 that was causing the issue. Not the case.
I'm using Delphi 10.2 with Windows 10 Professional. At the conclusion of my application, I'm cleaning up files, jpg and bmp files to be specific. Generally, I have the files to be deleted in a TLisbBox and run a loop to delete all picture files subject to deletion. If there is one file, there is no problem using DeleteFile('source'). If there is more than that, no files are deleted and the program terminates like it crashed. For a test, I created three buttons where the first button called for a DeleteFile('source1'), the second button called for a DeleteFile('source2'), etc. In this case, all files, no matter how many I do one at a time will be deleted and the program does not crash. It only fail to delete and crashes the program when files are set to delete from a loop. I would appreciate any help on how to navigate around this problem and be able to successfully complete a file cleanup routine. Thanks.
I'm a physicist and not a professional programmer. I'm writing a program in Delphi 10.2 on a Windows 10 Pro platform and I'm importing images into the program using TImage and then using the jpeg2bmp function to convert them to bmp. Once I have my bmp (must be a bmp to be passed into another program), I need to just erase the original jpg image. I've used erasefile for years with no problem, however, my program consistently shuts down on when the third jpg is being deleted. I've learned that it won't crash if I initially reduce the original jpg images down from about 4MB in size to about 400kb. Is there any code that would reduce the original jpg down to about 1/4 the original size before converting it to bmp? If not, is there any way to erase the files once I'm done with them where them given the fact the size seems to be in issue? BTW, I've tried TFile.Delete and get the same results. Thanks for any feedback or help.