Case sensitive Directory.Exists / File.Exists

c#, case-sensitive, directory, file, file-exists

Solution

Since Directory.Exists uses FindFirstFile which is not case-sensitive, no. But you can PInvoke FindFirstFileEx with an additionalFlags parameter set to FIND_FIRST_EX_CASE_SENSITIVE

Problem

Is there a way to have a case sensitive `Directory.Exists` / `File.Exists`since ``` Directory.Exists(folderPath) ``` and ``` Directory.Exists(folderPath.ToLower()) ``` both return `true`? Most of the time it doesn't matter but I'm using a macro which seems not to work if the path doesn't match cases 100%.

Original source

Related problems