<filesystem> header in Visual Studio 2012

One of the new supported C++ headers in Visual Studio 2012 is <filesystem>. It defines types and functions for working with files and folders. It’s not a C++11 header, but it’s part of the TR2 proposal, hence the namespace it uses, std::tr2::sys. Among others, the header provides functionality for creating, renaming, deleting, or checking the state and type of a path. It also offers support for iterating through the content of a folder. Unfortunately, the MSDN documentation is not that good; it’s rather a reference documentation, missing any examples.

Here is a simple sample that demonstrates some of the features from this new header.

And the output is

What’s missing from the code above is the print method, but that’s just about formatting details:

Leave a Reply