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

How To Understand File And Folder Paths In Programming

In this post, you’ll get answers to these questions:

  • What is the difference between the Dir, Directory and the Folder terms?
  • What is a Drive? What is a Directory?
  • What is a Path?
  • What does Full Path mean?
  • What does Absolute Path mean?
  • What is the Current Path?
  • What is a Short Path?
  • What does Relative Path mean?

By learning how to understand file and folder paths in programming, it will help you to easily build C++ applications with the use of a C++ IDE.

What do we mean by “Drive” in programming?

The Drive is the partition of a Disc that is format in the appropriate file format of an operating system . Generally it is shown by a drive letter with columns or a drive name with columns , (i.e.” C:” or “MyDrive:”) For example:

What does Dir, Directory or Folder mean?

The Directory term is the same as the Folder term that defines name of file container group in a file system hierarchy. Dir is the shorten of Directory term generally used in commands and in some path methods. For example;

What do programmers mean when they say “Path”?

Path is a list of directory names with slash-separated and followed by either a directory name or a file name. All these examples below are Path,

In these examples, the last Path example points a file while the others point a folder location.

How do I return the full path of a file?

Full Path is also known as Absolute Path, begins with a drive letter followed by a colon, such as D: For example this is a full path file name.

So full path should start with a drive letter or name.

What do programmers mean by “Current Path” or “Current Directory”?

Current Path is the path that is normally Path of your application that you are running. We can change the Current Path on runtime, so every new folder or file operation may occur in that path.

Current Directory is the Directory where we are in, in this example it is “Debug”. In some cases Current Directory is shown in Full Path as same in Current Path.

What is a “Relative Path”?

Relative Path is the path that is relative to a current directory. We can use a dot (.) and a double-dot (..) to translate it as the current directory and the parent directory. Here single dot represents the current directory itself and double dots are used for parent directory.

Let’s assume our app is at the “D:\Projects\MyProject\Win32\Debug\MyApp.exe” application, Thus Relative Path of this folder:

is equal to:

In C++ Builder, we can use RelativePath Method to get Relative Path of a Path String.

What do programmers mean by “Short Path”?

Short Path term is used to define old short 8.3 form of windows operating system.
ExtractShortPathName method to convert a path file name to the short 8.3 form. In other terms this method converts the file name, FileName, to the short 8.3 form. For example;
It return this Full Path

To this Short Path string,

ExtractShortPathName returns an empty string if the file or directory does not exist and ExtractShortPathName  is only available on Windows. The first parameter, FileName, can be a full path name.

What is a UNC Path?

UNC Path (Uniform (Universal or Unified) Naming Convention Path) is a syntax for accessing folders and files on a network of computers. For example,

C++ Builder has some UNC specific Path Manipulation Routines that allows to use UNC formats like isUNCPath, IsUNCRooted, ExpandUNCFileName Methods.

What is a URL Path?

URL Path (Uniform Resource Locator Path) is used to locate the address of any document or folder on the Internet. For example,

C++ Builder has a lot of specific methods in its SysUtils and IOUtils library that are included in VCL and FMX libraries. Some of these are grouped as Path Manipulation Routines which allow a user to edit, extract, get and set drive name, directory name, file name, file extensions. These methods are combined in Vcl.FileCtrlSystem.IOUtilsSystem.SysUtils libraries. These methods are easy to use and easy to get or set file path strings in that operating system. These can be used with other component properties like FileName property of OpenDialog, SaveDialog components. We can also check drives, files, or directories if they exist or not in that given path. And we can get file name from a given path string.

Is there a C++ Builder Example of using the Path methods?

Here is the full C++ example about the some of the Path Methods that we used in programming,

These above and all other Path Methods are listed in Path Manipulation Routines. You can use them in your applications.

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++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?