Does DeleteFile function returns immediatly?
-
Hello there, If i call DeleteFile on a file that's pretty large, does the function wait until the entire file is deleted before returning? Or does it return immediately? i.e., the control is passed to OS to complete the task of deletion and then return immediately? For e.g., if i am deleteing 5 files inside a loop and 2 of them happen to be larger size, will it wait until each file is completely deleted before going to the next one? If it doesn't, then there's a probability that when the next file is called by DeleteFile the previous one might still be in the process of deletion and it could fail. Is there a possibility like that?
-
Hello there, If i call DeleteFile on a file that's pretty large, does the function wait until the entire file is deleted before returning? Or does it return immediately? i.e., the control is passed to OS to complete the task of deletion and then return immediately? For e.g., if i am deleteing 5 files inside a loop and 2 of them happen to be larger size, will it wait until each file is completely deleted before going to the next one? If it doesn't, then there's a probability that when the next file is called by DeleteFile the previous one might still be in the process of deletion and it could fail. Is there a possibility like that?
-
Hello there, If i call DeleteFile on a file that's pretty large, does the function wait until the entire file is deleted before returning? Or does it return immediately? i.e., the control is passed to OS to complete the task of deletion and then return immediately? For e.g., if i am deleteing 5 files inside a loop and 2 of them happen to be larger size, will it wait until each file is completely deleted before going to the next one? If it doesn't, then there's a probability that when the next file is called by DeleteFile the previous one might still be in the process of deletion and it could fail. Is there a possibility like that?
As far as I know, the function returns immediately and the deletion occurs in the background. This is always true if the file is still opened (see DeleteFile[^] in the MSDN):
Quote:
The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed.
Overall, there should be no significant difference in time for large and small files because the file data itself are left unchanged on the disk. Only the directory entries are touched.