Initial commit
This commit is contained in:
40
Server/SysMonitor/SysMethods.cs
Normal file
40
Server/SysMonitor/SysMethods.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user