I\'m trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies.
Example:
<
The below works fine to the extent I tested... only catch is that the API used is available only in Vista.
static void Main(string[] args)
{
using (FileStream fs = File.OpenRead(@"D:\temp\case\mytest.txt"))
{
StringBuilder path = new StringBuilder(512);
GetFinalPathNameByHandle(fs.SafeFileHandle.DangerousGetHandle(), path, path.Capacity, 0);
Console.WriteLine(path.ToString());
}
}
[DllImport("kernel32.dll", SetLastError = true)]
static extern int GetFinalPathNameByHandle(IntPtr handle, [In, Out] StringBuilder path, int bufLen, int flags);