📄 filemutex.cs
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -