⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statictools.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client.Resource;
    using System;
    using System.IO;
    using System.Text;

    internal static class StaticTools
    {
        private static object lockObject = new object();

        public static string GetFullPath(string path)
        {
            if (path.IndexOf(':') == 1)
            {
                return path;
            }
            return Path.Combine(ImpsPathInfo.ApplicationDataDir, path);
        }

        public static bool IsEmptyDirectory(string path)
        {
            if (!Directory.Exists(path))
            {
                return true;
            }
            if (Directory.GetFiles(path).Length == 0)
            {
                return (Directory.GetDirectories(path).Length == 0);
            }
            return false;
        }

        public static void LogError(string logFile, Exception ex)
        {
            if (ex is LiveUpdateException)
            {
                LiveUpdateException exception = ex as LiveUpdateException;
                string message = exception.Message;
                if (exception.InnerException != null)
                {
                    message = message + "   信息:" + exception.InnerException.Message;
                }
                LogMessage(logFile, message);
            }
            else
            {
                LogMessage(logFile, ex.Message);
            }
        }

        public static void LogMessage(string logFile, string message)
        {
            if (string.IsNullOrEmpty(logFile))
            {
                throw new ArgumentNullException("logFile");
            }
            if (!string.IsNullOrEmpty(message))
            {
                logFile = GetFullPath(logFile);
                if (!Directory.Exists(Path.GetDirectoryName(logFile)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(logFile));
                }
                lock (lockObject)
                {
                    File.AppendAllText(logFile, "[" + DateTime.Now.ToString() + "] \r" + message + "\r\n", Encoding.UTF8);
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -