Solved

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

Posted on 2015-01-10
4
161 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 32

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

743 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

8 Experts available now in Live!

Get 1:1 Help Now