?? statictools.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)
{
return (!Directory.Exists(path) || ((Directory.GetFiles(path).Length == 0) && (Directory.GetDirectories(path).Length == 0)));
}
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 + -