Solved

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

Posted on 2015-01-10
4
180 Views
Last Modified: 2015-01-19
Hi:

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?

Thanks,
JohnB
0
Comment
Question by:jxbma
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 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)
0
 
LVL 28

Assisted Solution

by:pepr
pepr earned 250 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
0
 
LVL 33

Expert Comment

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

Sara
0
 
LVL 28

Expert Comment

by:pepr
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)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

815 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

12 Experts available now in Live!

Get 1:1 Help Now