create_directory Function

Creates a directory from a specified name but fails if non-existent intermediate directories are specified in the path.

template<class Path>
inline bool create_directory(
   const Path& Pval
);

Pval

An Path object that contains a directory path. Path can be either a path or a type that is derived from path.

true if the directory creation succeeds; false if the directory already exists.

If the directory cannot be created, for example if a non-existent intermediate directory is in the path, then the function throws a filesystem_error or, if you are using the noexcept overload, sets the error_code to errc::operation_not_permitted. Use create_directories if you need to create new intermediate directories on the fly.

    path myRoot("C:/FileSystemTest/");
    create_directory(myRoot);

Header: filesystem

Namespace: std::tr2::sys

Show: