-
Notifications
You must be signed in to change notification settings - Fork 18
/
Utils.cs
executable file
·48 lines (39 loc) · 1.06 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Principal;
namespace Gopher
{
class Utils
{
public static bool IsHighIntegrity()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
public static List<string> FindFiles(string path, string pattern)
{
List<string> files = new List<string>();
try
{
files.AddRange(Directory.GetFiles(path, pattern, SearchOption.TopDirectoryOnly));
foreach (string directory in Directory.GetDirectories(path))
{
files.AddRange(FindFiles(directory, pattern));
}
}
catch (Exception) { }
return files;
}
public static byte[] HexStringToByteArray(string hex)
{
byte[] ba = new byte[hex.ToString().Length / 2];
for (int i = 0; i < hex.ToString().Length; i += 2)
{
ba[i / 2] = Convert.ToByte(hex.ToString().Substring(i, 2), 16);
}
return ba;
}
}
}