I want to delete a folder which contains the currently running application. How can i do it..? is there any way of doing it ? i.e the folder which contains the application should delete after the application has finished running ?
I want to delete a folder which contains the currently running application. How can
Share
Your best bet is probably to use the Win32 API MoveFileEx. It has a flag that can be set for deleting files when they are in use on the next reboot called
MOVEFILE_DELAY_UNTIL_REBOOT. Set the new filename parameter ofMoveFileExtoNULLto perform this type of delete.Note: Normal files that are in use can be deleted normally using the Win32 API DeleteFile depending on if they were opened (Using the Win32 API
CreateFile) withFILE_SHARE_DELETEpermission. I don’t think running programs by default on Windows have that permission though. When a file is specified to be deleted that is in use but that was opened with this flag, then the file will be removed when the last file handle is closed.