[delphi] controleren wat het laatste teken

Pagina: 1
Acties:

  • JSchut
  • Registratie: Februari 2002
  • Laatst online: 21:28
ik heb een browsedialog gemaakt en daarmee kan je dus een directory selecteren

maar nu het probleem

als je hd C: selecteerd dan krijg ik "C:\" terug
en als ik een map selecteer krijg ik "C:\test" terug

als ik dat vervolgens ga gebruiken voor het opvragen van de files in de betreffende dir dan werkt het alleen als de dir eindigd op een \

hoe kan ik nou controleren of het laatste teken een \ is :?

PSN jschut_82 | Xbox: JSchut82


  • whoami
  • Registratie: December 2000
  • Laatst online: 21:42
code:
1
string[Length(string)]

dus
code:
1
2
if str[lenght(str)] = '\\' then begin
end;

https://fgheysels.github.io/


Verwijderd

Zie help:

function IsPathDelimiter(const S: string; Index: Integer): Boolean;

Description

Call IsPathDelimiter to determine whether a position in the string S contains the backslash path delimiter (?\?). The Index parameter specifies the position of the character in question, where 0 is the first byte, 1 is the second byte, and so on.

When working with a multi-byte character system (MBCS), IsPathDelimiter distinguishes between a true backslash character, and the byte of the same value that can appear as the second byte of a double byte character.

To test for more characters than just the backslash character, use IsDelimiter.

  • Kool
  • Registratie: September 1999
  • Niet online
IncludeTrailingBackslash

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 21:25

Creepy

Tactical Espionage Splatterer

Op donderdag 25 april 2002 12:21 schreef Kool het volgende:
IncludeTrailingBackslash
UIt de delphi help
function IncludeTrailingBackslash(const S: string): string;

Description

IncludeTrailingBackslash ensures that a path name ends with a trailing path delimiter ('\'). This function is included for backward-compatibility only. New programs should use IncludeTrailingPathDelimiter.

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


Verwijderd

code:
1
ExtractFileDir(filename);

haalt bij een directory de laatste "/" er voor je uit.

edit:
typo

  • Guillome
  • Registratie: Januari 2001
  • Niet online

Guillome

test

code:
1
ExtractFilePath(s);

Zet er een \ achter ;)

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router

Pagina: 1