Once 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.
Windows CE cannot delete a file that has an open handle.
Call the RemoveDirectory function, with the full path name of the directory in the lpPathName parameter, to delete a directory. You must delete all of the files in the directory before calling RemoveDirectory.