File Deletion

How would you delete a file or folder?  Also, how would you check if the file or folder exists in the indicated
drive?
strider031598Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
alexoConnect With a Mentor Commented:
I can give you  two answers:  one Win32 specific and one that uses the C standard runtime library.

Answers below...
0
 
alexoCommented:
The Win32 way:

DeleteFile() - deletes a file.

RemoveDirectory - deletes an empty directory.

To find if a file or directory exists, use FindFirstFile() or FindFirstFileEx().  Don't forget to terminate the search using FindClose().
Another way is to use GetFileAttributes().  The call will fail if the file does not exist.

A "standard" way described below...
0
 
alexoCommented:
A correction: the access() (or _access() on some compilers) function is much better for checking file/directory existence.
0
All Courses

From novice to tech pro — start learning today.