问题
For example,
I have an excutable TrashClean.exe running. I want it to delete all files I don't want and also delete itself (TrashClean.exe on hard drive) at last step.
I am wondering if it's possible in C#?
回答1:
Please see How To Make Your Application Delete Itself Immediately:
I'm sure you've all said to yourself or someone at the office at one point or another, "
<snort>You idiot. Don't you know a Windows application can't delete itself? I bet you don't even know how to type high ASCII characters using the ALT key and the number pad, gahhhh.."Sure, there are ways to have a file delete itself on the next reboot... And you can even resort to an external program or batch file to do the work. But I just came up with a nifty way of doing it without leaving a visible trace that the application ever existed!
来源:https://stackoverflow.com/questions/5303783/how-to-make-a-running-excutable-delete-its-own-file