filemutex.cs
来自「PDA程序PDA for windows CE take a look」· CS 代码 · 共 48 行
CS
48 行
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
namespace GasPDA
{
public class FileMutex
{
private FileStream aFile;
public FileMutex()
{
}
public bool Open()
{
string strAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
string strFile = strAppDir + @"\Log.txt";
try
{
aFile = new FileStream(strFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
}
catch
{
return false;
}
return true;
}
public void Dispose()
{
try
{
aFile.Close();
aFile = null;
}
catch
{
//Console.WriteLine("自动释放资源失败!");
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?