Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


What is best approach for managing and accessing files/directories/paths in a windows unmanaged C++ application?

Posted on 2015-01-10
Medium Priority
Last Modified: 2015-01-19

It's been a while since I've done unmanaged C++  in windows.

The File class in .Net makes handling/managing files pretty straight forward.

What is the best equivalent thing to do in unmanaged C++ which would make it relatively straightforward
to access/manipulate the filename, path, directory, etc.?

We are using the boost libraries in our project.
I know the boost libraries has boost::filesystem. I'm not quite familiar with that yet.
Is using the boost libraries the best approach?

Question by:jxbma
  • 2
LVL 86

Accepted Solution

jkr earned 1000 total points
ID: 40542727
The unmanaged part is done by the so called 'Shell Helper APIs', check out http://msdn.microsoft.com/en-us/library/windows/desktop/bb773559%28v=vs.85%29.aspx ("Shell Path Handling Functions"). As a side note, that's what .NET ends up calling when retrieving that information  ;o)
LVL 29

Assisted Solution

pepr earned 1000 total points
ID: 40543763
The Boost C++ Libraries is a kind of unofficial testbed for the C++ standardization process. Its documentation says (http://www.boost.org/doc/libs/1_57_0/libs/filesystem/doc/index.htm):
A proposal, N1975, to include Boost.Filesystem in Technical Report 2 has been accepted by the C++ Standards Committee. That proposal was based on version 2 of Boost.Filesystem; presumably the final TR2 form will be based on version 3.

To keep the sources as up-to-date as possible, you should probably follow the birth of C++14 standard and the later C++17. I did not follow the last development. Have a look at https://isocpp.org/std/status, and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3803.pdf
LVL 35

Expert Comment

ID: 40543880
for many tasks in unmanaged c++ you could be happy with std::ifstream and std::ofstream and std::fstream classes.

LVL 29

Expert Comment

ID: 40544136
@jxbma: To make the question clear... Do you mean the manipulation with paths (composing, splitting,...), creating directories, searching for files, testing for existence of a file/directory, getting the information about the file, etc.?

(See http://www.boost.org/doc/libs/1_57_0/libs/filesystem/doc/tutorial.html)

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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…

580 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