Correct text case of qualified file name for display purposes...

  • Thread starter Thread starter Nathan Baulch
  • Start date Start date
N

Nathan Baulch

Given an arbitary qualified file name which is guarenteed to exist:
"C:\WiNdOwS\MicROSoft.NeT\framEoRK\v1.1.4322\AcceSSibility.dLl"

I would like some means of getting the correct text case, as per the file
system:
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Accessibility.dll"

I can get a string with just the file name portion with the correct case:

string qualifiedFileName = Directory.GetFiles(
Path.GetDirectoryName(qualifiedFileName),
Path.GetFileName(qualifiedFileName))[0];

The only method I can think of to get the correct case for the directory
portion is to loop through each sub directory and use
Directory.GetDirectories() with a filter (similar to my usage of
Directory.GetFiles() above).

Is there a simpler way?


Nathan
 
Well... technically there is no such thing as "correct case", since FAT and
NTFS are case-insensitive. Other than what you're suggesting I don't see how
you could get the "correct" case shown in Explorer and such.
 
Back
Top