我想在C#中编写静态成员函数,或者在.NET Framework中找到一个将重新指定文件系统指定文件路径的文件路径。C#文件路径回收
例子:
string filepath = @"C:\temp.txt";
filepath = FileUtility.RecaseFilepath(filepath);
// filepath = C:\Temp.TXT
// Where the real fully qualified filepath in the NTFS volume is C:\Temp.TXT
我试过下面的下面的代码和它的许多变种,它仍然无法正常工作。 我知道Windows在一般情况下不区分大小写,但我需要将这些文件路径传递给ClearCase,因为它是Unix和Windows应用程序,所以它考虑文件路径大小写。
public static string GetProperFilePathCapitalization(string filepath)
{
string result = "";
try
{
result = Path.GetFullPath(filepath);
DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(result));
FileInfo[] fi = dir.GetFiles(Path.GetFileName(result));
if (fi.Length > 0)
{
result = fi[0].FullName;
}
}
catch (Exception)
{
result = filepath;
}
return result;
}
由于ClearCase。我已经在这个问题上说过了。 – 2009-01-28 05:10:05