AlexV
AlexV

Reputation: 23108

How can I get the correct text case of a user inputted file or directory in Delphi?

In my (Windows) program a user can input text and that text can be a file or a directory.

Now I want to fix the text case so that the input text match the file system case. For example if a user inputs:

C:\PROGRAM FILES\FOO\BAR

and the directory exists with this text case:

C:\Program Files\Foo\Bar

I want to return it with the later (correct) text case.

How would I do that in Delphi? I tried using FindFirst and FindNext, but I don't have the full path in the TSearchRec (of course I could split the string and do multiple FindFirst for each level, but there must be a better way).

I use Delphi 10.4 if it changes something.

Upvotes: 1

Views: 214

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597941

Open a handle to the file/directory using CreateFile(), and then you can use either:

Upvotes: 6

Related Questions