Files
DnnConnect2025Demo/Server/SysMonitor/SysMethods.cs
2025-05-10 20:37:54 +02:00

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;
}
}
}
}