Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I delete all files in directory using Boost in C++ (unmanaged Windows)?

Posted on 2015-01-22
2
Medium Priority
?
3,654 Views
Last Modified: 2015-01-25
Hi:

I have an unmanaged windows C++ app that's using the boost libraries.

What from the boost filesystem do I use to delete all file's from directory?
I create a Path based on a string path:

Path("c:\\SomePath");

At that point I'm not sure how to delete all the files that reside in that directory.
How do I do this?

Thanks,
JohnB
0
Comment
Question by:jxbma
[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
  • 2
2 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 40564723
You can do that using the native Windows API, boost isn't required for that. E.g.

SHFILEOPSTRUCT sfo;

ZeroMemory(&sfo,sizeof(sfo));

sfo.wFunc = FO_DELETE;
sfo.pFrom = FilePath;
sfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;

SHFileOperation(&sfo);

Open in new window


to delete a subtree in the file system.
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 40564742
BTW, if you want to do that with Boos, try 'remove_all()' (http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/reference.html#remove_all), e.g.

boost::filesystem::path p = "c:\\SomePath";

boost::filesystem::remove_all(p);

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

596 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