C# PathRelativePathTo正在将unicode字符转换为ascii

C# PathRelativePathTo正在将unicode字符转换为ascii,c#,unicode,C#,Unicode,我有以下功能: public static string GetRelativePath(string fromPath, string toPath) { // we also tried the Uri solution but that does not return .. when you need to traverse // one up only // uri1 = "bla\foo" // uri2

我有以下功能:

    public static string GetRelativePath(string fromPath, string toPath)
    {
        // we also tried the Uri solution but that does not return .. when you need to traverse
        // one up only
        // uri1 = "bla\foo"
        // uri2 = "bla\bar"
        // uri1.MakeRelaitveto(uri2) != "..\bar"
        var path = new StringBuilder(260); // MAX_PATH
        if (PathRelativePathTo(
            path,
            fromPath.Replace('/', '\\'),
            FILE_ATTRIBUTE_DIRECTORY,
            toPath.Replace('/', '\\'),
            FILE_ATTRIBUTE_DIRECTORY) == 0)
        {
            return toPath;
        }

        return path.ToString().Replace('\\', Path.DirectorySeparatorChar);
    }

    [DllImport("shlwapi.dll", SetLastError = true)]
    private static extern int PathRelativePathTo(
        StringBuilder pszPath, string pszFrom, int dwAttrFrom, string pszTo, int dwAttrTo);
}
我用以下测试用例调用它:

GetPathRelativeTo("C:\\somεpath", "C:\\anothεrpath").Shouldbe("..\\anothεrpath")
但它返回的是
。\\n另一条路径
。请注意,
ε
已替换为
e

我尝试使用
PathRelativePathToW
,但效果更差(其他测试用例失败)


有人知道发生了什么事以及我如何防止替换字符吗?

这似乎是引擎盖下的
shlwapi
的问题,而不是C侧的问题

考虑改用
System.Uri