This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
CC-Functions/Misc/Security.cs

25 lines
707 B
C#
Raw Normal View History

2019-11-29 21:27:24 +01:00
using System.IO;
2019-09-07 10:12:24 +02:00
using System.Security.Principal;
namespace Misc
{
public static class MiscFunctions
{
public static bool IsAdministrator => new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
2019-11-29 21:27:24 +01:00
2019-09-07 10:12:24 +02:00
public static long GetDirectorySize(string path)
{
try
{
string[] a = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
long size = 0;
for (int i = 0; i < a.Length; i++)
{
size += new FileInfo(a[i]).Length;
}
return size;
}
catch { throw; }
}
}
2019-11-29 21:27:24 +01:00
}