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

How To Include Or Exclude Trailing Backslashes On Windows

How can I add a trailing backslash to a path string? How can I remove trailing backslash from the end of path string? What is the C++ ExcludeTrailingBackslash method? What is the IncludeTrailingBackslash method? What is difference between the ExcludeTrailingBackslash and ExcludeTrailingPathDelimiter methods? What is the difference between IncludeTrailingBackslash and IncludeTrailingPathDelimiter methods?

C++ Builder has a lot of specific methods in its SysUtils library that is included in the VCL and FMX libraries. Some of these are grouped as a Path Manipulation Routines that allow users to edit, extract, get and set drive name, directory name, file name and file extensions. These methods are combined in the Vcl.FileCtrl, System.IOUtilsSystem.SysUtils libraries. These methods are easy to use and easy to get or set file path strings in that operating system. They 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 are exist or not on a given path. We can also get some specific directory locations like the “Current Directory”.

What is the C++ ExcludeTrailingBackslash method ?

The ExcludeTrailingBackslash Method (System.SysUtils.ExcludeTrailingBackslash) is a SysUtils Method that returns a path name without a trailing delimiter. This method is included for backward compatibility only. The System.SysUtils.ExcludeTrailingPathDelimiter should be used instead. ExcludeTrailingBackslash returns a UnicodeString, with the trailing path delimiter (PathDelim, ‘\’ on Windows, ‘/’ on Linux, macOS and mobile platforms) removed. Note that ExcludeTrailingBackslash works with multibyte character sets (MBCS).

What is the syntax of the ExcludeTrailingBackslash method?

Here is the ExcludeTrailingBackslash Method:

What is the C++ IncludeTrailingBackslash method ?

The IncludeTrailingBackslash Method (System.SysUtils.IncludeTrailingBackslash) is a SysUtils Method. It ensures that a path name ends with a delimiter. This method is included for backward compatibility only. System.SysUtils.IncludeTrailingPathDelimiter should be used instead. System.SysUtils.IncludeTrailingBackslash. IncludeTrailingBackslash ensures that a path name ends with the trailing path delimiter (PathDelim, ‘\’ on Windows, ‘/’ otherwise). Note that IncludeTrailingBackslash works with multibyte character sets.

What is the syntax of IncludeTrailingBackslash method ?

Here is the ExcludeTrailingBackslash Method:

What is a simple example of using the C++ ExcludeTrailingBackslash and IncludeTrailingBackslash methods?

ExcludeTrailingBackslash and IncludeTrailingBackslash methods both return UnicodeString. We can use them as given below,

and the outputs will be as follows respectively,

and,

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

Here is the full C++ Builder VCL example,

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.

close

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

33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux and some other operating systems. Dr. Yilmaz Yoru was born in 1974, Eskisehir-Turkey. He graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later he started to work in the same university as an assistant. He received his MSc and PhD degrees from the same department of the same university. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations.
Related posts
C++ComponentsDatabaseIntroduction to C++Language FeatureLearn C++

Get To Know The Powerful C++ Data Bindings In Windows Apps

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

How to Create a New Windows FMX Static Library In C++

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

How To Use C++ front() And back() Methods Of Vectors

C++Generic ProgrammingIntroduction to C++Language FeatureLearn C++

5 Things You Need To Know About Optimization In C++ Builder

ru_RURussian