1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
AlexV
  • 22,658
  • 18
  • 85
  • 122
  • 1
    Linking to [Is it safe to assume that Windows local and network file paths are NOT case sensitive?](https://stackoverflow.com/q/7199039/4299358) - with _Windows_ now supporting sub systems like _Unix_ case sensitivity must be expected more than in the past. – AmigoJack Oct 03 '21 at 04:02

1 Answers1

6

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

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770