This commit is contained in:
2024-04-03 08:48:41 +03:00
parent 0da3cff0ca
commit f572ea30cc
2 changed files with 12 additions and 3 deletions

View File

@@ -10,12 +10,21 @@ public static class LikeDelphi
{
/// <summary>
/// Аналог функции IncludeTrailingBackslash
/// версия 2.1 (20240403) - исправлена ошибка;
/// версия 2.0 (20231213) - ОС-независимая реализация.
/// </summary>
/// <param name="path">Путь, к которому нужно добавить slash</param>
/// <returns>Путь со slash в конце</returns>
public static string IncludeTrailingBackslash(string path) =>
$"{path.TrimEnd(Path.PathSeparator)}{Path.PathSeparator}";
public static string IncludeTrailingBackslash (string path)
{
// Если path не заканчивается slash-ем
if (!path.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
// - то добавляем slash
path += Path.DirectorySeparatorChar;
// Выводим результат
return path;
}
/// <summary>
/// Парсер строки в множество строк