DocSpace-client/common/ASC.Common/Utils/CrossPlatformUtils.cs

27 lines
712 B
C#
Raw Normal View History

2022-03-15 16:59:24 +00:00
namespace ASC.Common.Utils;
public static class CrossPlatform
{
2022-02-10 12:14:50 +00:00
private static char[] _pathSplitCharacters = new char[] { '/', '\\' };
public static string PathCombine(string basePath, params string[] additional)
{
2022-02-10 12:14:50 +00:00
var splits = additional.Select(s => s.Split(_pathSplitCharacters)).ToArray();
var totalLength = splits.Sum(arr => arr.Length);
var segments = new string[totalLength + 1];
segments[0] = basePath;
var i = 0;
2022-02-03 14:18:58 +00:00
foreach (var split in splits)
{
foreach (var value in split)
{
i++;
segments[i] = value;
}
}
return Path.Combine(segments);
}
}