forked from tejashwikalptaru/csharp-clamAV-antivirus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistory.cs
99 lines (94 loc) · 3.06 KB
/
History.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TejashPlayer;
using System.IO;
using System.Text.RegularExpressions;
namespace AntiVirus_Project
{
class History
{
private IniFile ini = null;
private string loc = string.Empty;
public List<string> file_names = new List<string>();
public List<string> vir_name = new List<string>();
public History()
{
loc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
loc = loc + "\\NetSky\\";
if (Directory.Exists(loc))
{
loc = loc + "NetSky_History.db";
if (File.Exists(loc))
{
ini = new IniFile(loc);
string t = ini.IniReadValue("Total_History", "Value");
if (t.Trim().Length > 0)
{
int total = Convert.ToInt32(t);
for (int i = 1; i <= total; i++)
{
string h = ini.IniReadValue("History", i.ToString());
if (h.Trim().Length > 0)
{
string[] data = Regex.Split(h, "#GAP#");
if (data.Length == 2)
{
file_names.Add(data[0]);
vir_name.Add(data[1]);
}
}
}
}
}
else
{
File.Create(loc);
}
}
else
{
Directory.CreateDirectory(loc);
File.Create(loc + "Netsky_History.db");
loc = loc + "Netsky_History.db";
}
}
public void AddHistory(string file, string vir_name)
{
IniFile ins = new IniFile(loc);
int index = 0;
string t = string.Empty;
try
{
t = ins.IniReadValue("Total_History", "Value");
}
catch { }
if (t.Trim().Length > 0)
{
index = Convert.ToInt32(t);
index++;
}
else
index++;
string val = file + "#GAP#" + vir_name;
file_names.Add(file);
this.vir_name.Add(vir_name);
ins.IniWriteValue("History", index.ToString(), val);
ins.IniWriteValue("Total_History", "Value", index.ToString());
}
public void DelHistory()
{
if(File.Exists(loc))
{
try
{
File.Delete(loc);
file_names = null;
vir_name = null;
}
catch { }
}
}
}
}