mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-31 10:29:52 +08:00
25 lines
486 B
C#
25 lines
486 B
C#
using System.IO;
|
|
|
|
namespace MicaSetup.Helper;
|
|
|
|
public static class FileWritableHelper
|
|
{
|
|
public static bool CheckWritable(string fileName)
|
|
{
|
|
if (!File.Exists(fileName))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
try
|
|
{
|
|
using FileStream fileStream = new(fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
|
return fileStream.CanWrite;
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|