Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to exclude trailing back slash problems Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Exclude trailing back slash problems 20-Jul-04
Category
Files Operation
Language
Delphi All Versions
Views
347
User Rating
3
# Votes
1
Replies
0
Publisher:
Philipp, Steve
Reference URL:
			Email Address: Support@HeuristicResearch.com

One handy and innocent-looking Delphi function in SysUtils is:
  Path := ExcludeTrailingBackslash(Path);
It is failsafe when you use it to append a filename after it, like:
  FileName := ExcludeTrailingBackSlash(Path) + '\MyFileName';
But if you have a foldername for folder operations WITHOUT appending a filename,
you may get surprise crashes with root-folders.
  C:\AFolder
is a valid folder name, but if you remove the backslash from C:\ then you get
  C:
which is not a valid folder name!
So unless you are sure you'll attach a filename with a backslash,
be sure to adjust:
  if Copy(Path, Length(Path), 1) = ':' then Path := Path + '\';

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC