Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Closing and Deleting Files

To use operating system resources efficiently, an application should close files when they are no longer needed by using the CloseHandle function. If a file is open when an application terminates, the system closes it automatically.

The DeleteFile function can be used to delete a file on close. A file cannot be deleted until all handles to it are closed. If a file cannot be deleted, its name cannot be reused. To reuse a file name immediately, rename the existing file.

If you are deleting an open file or directory on a remote machine and it has already been opened on the remote machine without the read share permission set, do not call CreateFile or OpenFile to open the file or directory for deletion first. Doing so will result in a sharing violation.

 

 

Show:
© 2017 Microsoft