Solved

File Deletion

Posted on 1998-05-17
3
178 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 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