41 lines
937 B
C#
41 lines
937 B
C#
using System.IO;
|
|
|
|
namespace Bring2mind.DnnConnect2025Demo.SysMonitor
|
|
{
|
|
internal class SysMethods
|
|
{
|
|
public static string GetWebConfigMd5(string webConfigPath)
|
|
{
|
|
var fileBytes = File.ReadAllBytes(webConfigPath);
|
|
var md5 = System.Security.Cryptography.MD5.Create();
|
|
var hash = md5.ComputeHash(fileBytes);
|
|
var md5String = System.BitConverter.ToString(hash).Replace("-", "").ToLower();
|
|
return md5String;
|
|
}
|
|
|
|
public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
|
|
{
|
|
try
|
|
{
|
|
using (FileStream fs = File.Create(
|
|
Path.Combine(
|
|
dirPath,
|
|
Path.GetRandomFileName()
|
|
),
|
|
1,
|
|
FileOptions.DeleteOnClose)
|
|
)
|
|
{ }
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
if (throwIfFails)
|
|
throw;
|
|
else
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|