?
Solved

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

Posted on 2015-01-10
4
Medium Priority
?
257 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
[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
4 Comments
 
LVL 86

Accepted Solution

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

Assisted Solution

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

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 29

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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.
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.

770 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