C++Introduction to C++Language FeatureLearn C++

How To Use ForceDirectories Method To Create Folders In C++

How To Use ForceDirectories Method To Create Folders In C++

ForceDirectories Method (System:SysUtils:ForceDirectories) is a SysUtils Method listed in Disk And Directory Support Routines that creates a new directory, including the creation of parent directories as needed. ForceDirectories creates a new directory as specified in Dir, which must be a fully-qualified pathname. If the directories given in the path do not yet exist, ForceDirectories attempts to create them.

In this post, you’ll learn how to use Force Directories Method, Syntax of ForceDirectories to create folders in c++ and its examples. By learning Force Directories Methods. it will help you to easily build C++ applications using the C++ IDE.

Here is the Syntax of ForceDirectories Method in C++ Builder

ForceDirectories returns True if it successfully creates all necessary directories, False if it could not create a needed directory.

Note that, do not call ForceDirectories with an empty string. Doing so causes ForceDirectories to raise an exception. The Vcl.FileCtrl unit (Windows only) contains a ForceDirectories function that is deprecated. System.SysUtils.ForceDirectories is preferred, and can be used in multi-device applications.

Here is a simple example of using the ForceDirectories() Method in C++

A full examples of how to create folders with the C++ ForceDirectories Method

Here is the full simple example to ForceDirectories() method,

This example above will create “MyFolder”, “MySubFolder” and “MyOtherSubFolder” directories together.

Here’s another example showing how to create folders or directories in C++

Here we used different creating directory methods in a single C++ Builder example which shows how it is flexible to use different methods,

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20

What Is The Stack (std::stack) In Modern C++?

C++C++11C++14C++17C++20Learn C++

What Is The Queue (std::queue) In Modern C++?

C++C++11C++14C++17Learn C++SyntaxTemplates

What Are The Logical Operation Metafunctions In Modern C++?

C++C++14C++17C++20Learn C++

What Are The Deprecated C++14 Features In C++17?