Solved

File Deletion

Posted on 1998-05-17
3
176 Views
Last Modified: 2010-04-10
How would you delete a file or folder?  Also, how would you check if the file or folder exists in the indicated
drive?
0
Comment
Question by:strider031598
  • 3
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 40 total points
Comment Utility
I can give you  two answers:  one Win32 specific and one that uses the C standard runtime library.

Answers below...
0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
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
 
LVL 11

Expert Comment

by:alexo
Comment Utility
A correction: the access() (or _access() on some compilers) function is much better for checking file/directory existence.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now