Deleting a File or a Directory

Windows CE 3.0

After you are finished with a file, close the file handle by using the CloseHandle function. CloseHandle is a generic function that closes a variety of handles, including the handle to a file. If you leave a file open when your application terminates, Windows CE automatically closes the file.

To close and delete a file

  1. Close the file by calling the CloseHandle function.
  2. Delete the file by calling the DeleteFile function.

    Windows CE cannot delete a file that has an open handle.

Call the RemoveDirectory function, with the full path of the directory in the lpPathName parameter, to delete a directory. You must delete all of the files in the directory before calling RemoveDirectory.


Show: