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

How To Include And Exclude Path Delimiters On Windows

C++ Builder has a lot of specific methods in its SysUtils library that are included in the vcl and fmx libraries. Some of these are grouped as a Path Manipulation Routines that allows users to edit, extract, get and set drive name, directory name, file name, and file extensions. These methods are combined in Vcl.FileCtrl, System.IOUtilsSystem.SysUtils libraries. These all 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 to see if they exist or not on a given path. We can include and exclude path delimiters on Windows.

In this post, you’ll learn how to add a path delimiter to a path string. What is the C++ ExcludeTrailingPathDelimiter, What is the IncludeTrailingPathDelimiter method, What is the difference between ExcludeTrailingBackslash, and ExcludeTrailingPathDelimiter methods, and What is the difference between IncludeTrailing PathDelimiter and IncludeTrailing PathDelimiter methods? Learning how to use, include, and exclude path delimiters on Windows will allow you to easily build C++ applications using the C++ IDE.

Where can I see more examples of the Path Manipulation routines?

Go to this tag search: https://learncplusplus.org/tag/path-manipulation-routines/

What is the C++ ExcludeTrailingPathDelimiter method ?

The ExcludeTrailingPathDelimiter Method (System.SysUtils.ExcludeTrailingPathDelimiter) is a SysUtils Method that returns a path name without a trailing delimiter. In another terms this method returns UnicodeString, with the trailing path delimiter (PathDelim, ‘\’ on Windows, ‘/’ otherwise) removed. If the last character in S is not a delimiter, then S is returned unchanged. Note that ExcludeTrailingPathDelimiter works with multibyte character sets (MBCS).

PlatformSample Input (S)Output
WindowsC:\Your\Input\Path
C:\Your\Input\Path\
C:\Your\Input\Path
C:\Your\Input\Path
OS X
iOS
Android
Linux
/Your/Input/Path
/Your/Input/Path/
/Your/Input/Path
/Your/Input/Path

What is the syntax of ExcludeTrailingPathDelimiter method ?

Here is the ExcludeTrailingPathDelimiter Method:

What is the C++ IncludeTrailingPathDelimiter method ?

IncludeTrailingPathDelimiter Method (System.SysUtils.IncludeTrailingPathDelimiter) is a SysUtils Method that ensures that path name ends with a delimiter. In other terms this method ensures that a path name ends with a trailing path delimiter (PathDelim, ‘\’ on Windows, ‘/’ otherwise). If S already ends with a trailing delimiter character, it is returned unchanged; otherwise, S is returned with an appended delimiter character. Note that IncludeTrailingPathDelimiter works with multibyte character sets (MBCS).

PlatformSample Input (S)Output
WindowsC:\Your\Input\Path
C:\Your\Input\Path\
C:\Your\Input\Path\
C:\Your\Input\Path\
OS X
iOS
Android
Linux
/Your/Input/Path
/Your/Input/Path/
/Your/Input/Path/
/Your/Input/Path/

What is the syntax of IncludeTrailingPathDelimiter method?

Here is the IncludeTrailingPathDelimiter Method:

What are the simple examples of using the C++ ExcludeTrailingPathDelimiter and IncludeTrailingPathDelimiter methods?

ExcludeTrailingPathDelimiter and IncludeTrailingPathDelimiter methods return UnicodeString, we can use them as given below,

and the outputs will be as follows respectively,

and,

Here is a full example of the C++ ExcludeTrailingBackslash and IncludeTrailingBackslash methods

Here is the example how we check if a directory exists or not,

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.

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++?