Matt Matt - 4 months ago 9
Linux Question

How do I determine whether the filesystem is case-sensitive in .net?

Does .net have a way to determine whether the local filesystem is case-sensitive?

M4N M4N
Answer

You can create a file in the temp folder (using lowercase filename), then check if the file exists (using uppercase filename), e.g:

string file = Path.GetTempPath() + Guid.NewGuid().ToString().ToLower();
File.CreateText(file).Close();
bool isCaseInsensitive = File.Exists(file.ToUpper());
File.Delete(file);