基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
/******************************
|
||||
* 说明:公共方法
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-01-23
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.SocketService
|
||||
{
|
||||
/// <summary>
|
||||
/// 公共方法
|
||||
/// </summary>
|
||||
public class BasicFunc
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:检测文件是否在使用</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fileName">Name of the file.</param>
|
||||
/// <returns><c>true</c> if [is file in use] [the specified file name]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsFileInUse(string fileName)
|
||||
{
|
||||
bool inUse = true;
|
||||
FileStream fs = null;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);
|
||||
inUse = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
inUse = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fs != null)
|
||||
fs.Close();
|
||||
}
|
||||
return inUse;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:MD5加密</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string MD5String(string value)
|
||||
{
|
||||
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||
byte[] data = Encoding.Default.GetBytes(value);
|
||||
byte[] md5Data = md5.ComputeHash(data);
|
||||
md5.Clear();
|
||||
string result = "";
|
||||
for (int i = 0; i < md5Data.Length; i++)
|
||||
{
|
||||
result += md5Data[i].ToString("x").PadLeft(2, '0');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取本地时间时间戳</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-25 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.Int64.</returns>
|
||||
public static long GetCurrentTimeUnix()
|
||||
{
|
||||
TimeSpan cha = (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
|
||||
long t = (long)cha.TotalSeconds;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user