-
Notifications
You must be signed in to change notification settings - Fork 1
/
Stuff.cs
37 lines (36 loc) · 1.14 KB
/
Stuff.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
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace ReallyBasicExampleProtector
{
public static class Stuff
{
private static string[] allowed = { ".exe", ".dll" };
public static string fileType = string.Empty;
public static bool verifyIfAllowed(string x)
{
if (!allowed.Any(s => x.EndsWith(s)))
{
MessageBox.Show(String.Format("Only \"{0}\" are allowed", string.Join(", ", allowed).Replace(".", string.Empty)));
return false;
}
fileType = Path.GetExtension(x);
return true;
}
public static bool verifyIfExist(string x)
{
if (!File.Exists(x))
{
MessageBox.Show(String.Format("The file \"{0}\" doesn't exist", getFileName(x)));
return false;
}
return true;
}
public static string getFileName(string x)
{
string[] fileSplit = x.Split('\\');
return fileSplit[fileSplit.Length - 1].ToString();
}
}
}