.netlinuxmonofilesystemscase-sensitive

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?


Solution

  • 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);