GetFullPathに代わるものは見つかりませんでしたが、GetFullPathのような親ディレクトリトークン(.. \)を処理するメソッドを開発しました。
ここにあります:
public static string NormalizePath(string path)
{
if (String.IsNullOrEmpty(path) == false)
{
// Correct multiple backslashes
path = Regex.Replace(path, @"\\+", @"\");
// Correct parent directory tokens with too many points in it
path = Regex.Replace(path, @"\\\.\.+", @"\..");
// Split the path into tokens
List<string> resultingPathTokens = new List<string>();
var pathTokens = path.Split('\\');
// Iterate through the tokens to process parent directory tokens
foreach (var pathToken in pathTokens)
{
if (pathToken == "..")
{
if (resultingPathTokens.Count > 1)
{
resultingPathTokens.RemoveAt(resultingPathTokens.Count - 1);
}
}
else
{
resultingPathTokens.Add(pathToken);
}
}
// Get the resulting path
string resultingPath = String.Join("\\", resultingPathTokens);
// Check if the path contains only two chars with a colon as the second
if (resultingPath.Length == 2 && resultingPath[1] == ':')
{
// Add a backslash in this case
resultingPath += "\\";
}
return resultingPath;
}
return path;
}