Solved

File Deletion

Posted on 1998-05-17
3
177 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
ID: 1162311
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
ID: 1162312
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
ID: 1162313
A correction: the access() (or _access() on some compilers) function is much better for checking file/directory existence.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

910 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

20 Experts available now in Live!

Get 1:1 Help Now