You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
1.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.IO;
namespace Sog
{
public enum OSType
{
None = 0,
Windows = 1,
Linux = 2,
}
public static class OSUtils
{
private static OSType m_osType = OSType.None;
public static bool IsWindows()
{
Init();
return m_osType == OSType.Windows;
}
/// <summary>
/// 判断是否存在逻辑不是很严格,能用就行
/// </summary>
/// <returns></returns>
private static void Init()
{
if(m_osType != OSType.None)
{
return;
}
if (Directory.Exists("C:") || Directory.Exists("D:"))
{
m_osType = OSType.Windows;
}
else
{
m_osType = OSType.Linux;
}
}
public static string GetFilePathSeparator()
{
if(IsWindows())
{
return "\\";
}
else
{
return "/";
}
//return Path.DirectorySeparatorChar;
}
}
}