We have a C# .Net client application that sends some commands via REST over HTTP. The server is on a Linux machine written in Perl.
These commands contain file paths located on the server that can be entered by the user. Since the users are on windows, we'd like for them to be case-insensitive, but this is giving us some issues in locating the files server side.
How can we get the correct casing?
We have 2 possible solutions:
Use a winapi call on the client to fix the path to be properly cased. (These files are visible by a shared folder on the clients computer)
Use some perl code on the server to locate a file with a case-insensitive path as input
Any suggestions? We would like this to work on all client machines that are Windows XP SP2 and higher.
UPDATE: We decided it should be fixed client side, on the rare case that there is a case mismatch.
We run this if we get a "file not found" error on the directory of the file. Someone would have to modify this to work for files as well, but in our case the filename could never be wrong (I'd rather not explain why):
string FixDirectory(string fullpath)
{
return fullpath
.Split(Path.DirectorySeparatorChar)
.Skip(1)
.Select(path =>
{
string[] split = fullpath.Split(new string[] { path }, StringSplitOptions.None);
string tempDir = split[0];
string[] dirs = Directory.GetDirectories(tempDir, path);
fullpath = fullpath.Replace(Path.Combine(tempDir, path), dirs[0]);
return fullpath;
})
.Last();
}