I have a scenario where I create a html file and open it on Internet explorer by using windows shell32.dll and then delete it by using os-delete command. This html file does not delete completely until I close my web browser. This html file is showing in directory however I can not open it. This is causing issue when the same process runs again and try to create a new html file with same name and web browser is not closed. This is working fine with windows 7 but causing issue on Windows 10 only.
I tried various options like OS-command del \f but did not resolve the issue. It seems like IE keeps temporary files and does not delete until I close web browser manually.
Is anyone has any idea or workaround?
An easy workaround is to generate a unique filename for your html file. This way it does not matter whether an old file exist and - as a bonus - allows for multiple users generating the same file at the same time.
But beware of the folder becoming full if you do not clean up the files. I had this once on a server where I generated random file names, consisting of 6 numbers. After about a year, the process of generating a new file became slow, because it took a random number, checked whether that number was already in use and then generated the file. But after a year, almost all numbers were used, resulting in long generation time for a new file and a VERY full folder.
Another thing you could try is to rename the file prior to deletion. Then even if it hangs around, it doesn't interfere with the filename you need.