APG.CodeHelper.StringHelper.CorrectPath C# (CSharp) Method

CorrectPath() public static method

‘ункци¤ убирает из строки встречающиес¤ чаще одного раза знаки "\" и добавл¤ет в конец строки "\", если он там отсутствует. »сключение составл¤ет путь в формате UNC (строка начинаетс¤ с "\\")
public static CorrectPath ( string incorrectPath ) : string
incorrectPath string ѕуть
return string
        public static string CorrectPath(string incorrectPath)
        {
            string pattern = "\\\\{2,}|(?<tail>[^\\\\]$)";

            Uri uri = new Uri(incorrectPath);

            if (uri.IsUnc)
                pattern = "(?<tail>[^\\\\]$)";

            return Regex.Replace(incorrectPath, pattern, "${tail}\\");
        }