Solved

File Deletion

Posted on 1998-05-17
3
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

626 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