Since I'm using a macro which seems to work if the given path is case unequal to the local path on the drive I first need to validate wether the path is case-wise existing or not. Unfortunately (in my case) Directory.Exists()
is not case sensitive.
So I tried FindFirstFileEx with dwAdditionalAttributes
set to 1
which stands for FIND_FIRST_EX_CASE_SENSITIVE. However it seems not work for me. My local path is C:\Dir1\Dir2\Dir3
. The path I compare is C:\dir1\Dir2\Dir3
. Unfortunately I always get Dir3
as a result. I would have expected an empty result if the cases don't match.
What is my fault?
string dir = @"C:\Dir1\Dir2\Dir3" + '\0';
int FIND_FIRST_EX_CASE_SENSITIVE = 1;
WIN32_FIND_DATA fi;
IntPtr h = FindFirstFileEx( dir,
FINDEX_INFO_LEVELS.FindExInfoStandard,
out fi,
FINDEX_SEARCH_OPS.FindExSearchNameMatch,
IntPtr.Zero,
FIND_FIRST_EX_CASE_SENSITIVE);
This functionality depends on value of registry key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive
being set set to 0, which is not the default.
In other words, it depends on underlying file system settings, not the API itself.
more details here: http://www.siao2.com/2010/12/08/10101148.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With