zhaolei
8 days ago 4a2e5b9a21940f11757be37d99f0944e240e908b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#if !NET45
using System.IO;
using System.Runtime.InteropServices;
 
namespace System
{
    internal static class OSPlatformPathExtenstions
    {
        /// <summary>
        /// 获得 当前操作系统目录分隔符的路径
        /// </summary>
        /// <param name="originalString">原始路径字符串</param>
        /// <returns></returns>
        public static string GetOSPlatformPath(this string originalString)
        {
            var sp = Path.DirectorySeparatorChar;
            var win = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
            return win ? originalString.Replace('/', sp) : originalString.Replace('\\', sp);
        }
    }
}
#endif