Главная

Популярная публикация

Научная публикация

Случайная публикация

Обратная связь

ТОР 5 статей:

Методические подходы к анализу финансового состояния предприятия

Проблема периодизации русской литературы ХХ века. Краткая характеристика второй половины ХХ века

Ценовые и неценовые факторы

Характеристика шлифовальных кругов и ее маркировка

Служебные части речи. Предлог. Союз. Частицы

КАТЕГОРИИ:






ПАЙДАЛАНЫЛҒАН ӘДЕБИЕТТЕР ТІЗІМІ




 

1. Б. Досыбаев. Интернет көшінен кеш қалмайық //Егемен Қазақстан, 2002 жыл. – 27 шілде

 

2. Абрамов С.А., Зима Е.В. Начала информатики. -М.: Наука, 1989. -256 с.

 

3. Александр Колесников. Іnternet для пользователя. - Киев: BHV, 2000

 

4. Кручинин В.В. Разработка компьютерных учебных программ – Томск, 1998

 

5. Аткинсон Леон. MySQL. Библиотека профессионала. - М.: Издательский дом "Вильяме", 2002.

 

 

Осымша

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.IO;

using System.Text.RegularExpressions;

using System.Data.SqlClient;

namespace WindowsFormsApplication1

{

public partial class Form1: Form

{

int virus;

string[] virusList = new string[] { "virus", "trojan", "hacker", };

List<string> search= Directory.GetFiles(@"C:/", "*.*").ToList();

//(@"C:/", "*.*").ToList();

 

 

public Form1()

{

InitializeComponent();

}

 

#region ListBoxItem

private void button4_Click(object sender, EventArgs e)

{

try {

if (MessageBox.Show("Сіз таңдалған файлды жоюға сенімдісіз бе?", "My Application",

MessageBoxButtons.YesNo, MessageBoxIcon.Question)

== DialogResult.Yes)

{

File.Delete(listBox1.SelectedItem.ToString());

listBox1.Items.Remove(listBox1.SelectedItem);

}

}

catch(Exception ex)

{ MessageBox.Show(ex.Message);

}

}

 

private void button5_Click(object sender, EventArgs e)

{

try {

if (MessageBox.Show("Сіз барлық файлдарды жоюға сенімдісіз бе?", "My Application",

MessageBoxButtons.YesNo, MessageBoxIcon.Question)

== DialogResult.Yes)

{

 

foreach (string s in listBox1.Items)

{

File.Delete(s);

}

listBox1.Items.Clear();

MessageBox.Show("Барлық файлдар сәтті жойылды");

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

 

 

private void button6_Click(object sender, EventArgs e)

{

try {

if (MessageBox.Show("Сіз таңдалған файлдарды вирустар тізімінен шығаруға сенімдісіз бе?", "My Application",

MessageBoxButtons.YesNo, MessageBoxIcon.Question)

== DialogResult.Yes)

{

listBox1.Items.Remove(listBox1.SelectedItem);

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

#endregion

 

#region Scan

 

private void button7_Click(object sender, EventArgs e)

{

listBox1.Items.Clear();

if (radioButton1.Checked || radioButton2.Checked || radioButton3.Checked)

{

#region Quick Scan

if (radioButton1.Checked)

{

 

foreach (string item in search)

{

try

{

StreamReader stream = new StreamReader(item);

string read = stream.ReadToEnd();

foreach (string st in virusList)

{

if (Regex.IsMatch(read, st))

{

virus += 1;

label1.Text = "Вирустар саны:" + virus.ToString();

listBox1.Items.Add(item);

}

progressBar1.Increment(1);

 

}

stream.Close();

 

}

 

catch (Exception ex)

{

string s = ex.Message;

listBox1.Items.Add(s);

}

}

MessageBox.Show("Тексеру сәтті аяқталды! Тексерілген файлдар саны:" + search.Count);

 

}

#endregion

#region Selected Scan

else if (radioButton2.Checked)

{

 

foreach (string item in search)

{

try

{

StreamReader stream = new StreamReader(item);

string read = stream.ReadToEnd();

foreach (string st in virusList)

{

if (Regex.IsMatch(read, st))

{

virus += 1;

label1.Text = "Вирустар саны:" + virus.ToString();

listBox1.Items.Add(item);

}

progressBar1.Increment(1);

 

}

stream.Close();

 

}

 

catch (Exception ex)

{

string s = ex.Message;

listBox1.Items.Add(s);

}

}

MessageBox.Show("Тексеру сәтті аяқталды! Тексерілген файлдар саны:" + search.Count);

 

}

#endregion

 

#region Full Scan

else if (radioButton3.Checked)

{

search.Clear();

#region Search Folders

// foreach (string s in Directory.GetLogicalDrives())

foreach (DriveInfo s in DriveInfo.GetDrives().Where(x => x.IsReady == true))

{

 

foreach (string d in Directory.GetDirectories(s.ToString()))

{

if (search.Count == 0)

{

try

{

foreach (string f in Directory.GetFiles(d, "*.*", SearchOption.AllDirectories))

// EnumerateFiles(d, "*.*", SearchOption.AllDirectories))

{//GetFiles(d, "*.*", SearchOption.AllDirectories))//

 

try

{

search.Add(f);

 

}

catch (System.Exception excpt)

{

MessageBox.Show(excpt.Message);

}

 

}

}

catch (UnauthorizedAccessException)

{

 

}

}

}

}

 

 

#endregion

 

#region Scan

foreach (string item in search)

{

try

{

StreamReader stream = new StreamReader(item);

string read = stream.ReadToEnd();

foreach (string st in virusList)

{

if (Regex.IsMatch(read, st))

{

virus += 1;

label1.Text = "Вирустар саны:" + virus.ToString();

listBox1.Items.Add(item);

}

progressBar1.Increment(1);

 

}

stream.Close();

 

}

 

catch (Exception ex)

{

string s = ex.Message;

listBox1.Items.Add(s);

}

}

progressBar1.Value = 10000;

MessageBox.Show("Тексеру сәтті аяқталды! Тексерілген файлдар саны:" + search.Count);

 

#endregion

 

 

}

#endregion

 

radioButton4.Select();

 

 

}

 

 

else

{

MessageBox.Show("Тексеру әдісін таңдаңыз!");

}

 

}

 

#endregion

 

#region RadioButtonSelect

private void radioButton1_CheckedChanged(object sender, EventArgs e)

{

try

{

if (radioButton1.Checked)

{

search.Clear();

folderBrowserDialog1.ShowDialog();

label2.Text = folderBrowserDialog1.SelectedPath;

virus = 0;

label1.Text = "Вирустар саны:" + virus.ToString();

progressBar1.Value = 0;

// listBox1.Items.Clear();

search = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.*", SearchOption.TopDirectoryOnly).ToList();;//.AllDirectories).ToList();

progressBar1.Maximum = search.Count;

}

}

catch (Exception ex)

{

 

}

}

 

private void radioButton2_CheckedChanged(object sender, EventArgs e)

{

try

{

if (radioButton2.Checked)

{

search.Clear();

folderBrowserDialog1.ShowDialog();

label2.Text = folderBrowserDialog1.SelectedPath;

virus = 0;

label1.Text = "Вирустар саны:" + virus.ToString();

progressBar1.Value = 0;

// listBox1.Items.Clear();

search = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.*", SearchOption.AllDirectories).ToList();

progressBar1.Maximum = search.Count;

}

}

catch (Exception ex)

{

 

}

}

 

private void radioButton3_CheckedChanged(object sender, EventArgs e)

{

search.Clear();

virus = 0;

label1.Text = "Вирустар саны:" + virus.ToString();

progressBar1.Value = 0;

progressBar1.Maximum = 10000;

 

}

 

#endregion

 

#region carantin

private void button1_Click(object sender, EventArgs e)

{

try

{

SqlConnection connection = new SqlConnection();

SqlCommand comand = new SqlCommand();

SqlDataAdapter adaptor = new SqlDataAdapter();

DataSet dataset = new DataSet();

connection.ConnectionString = (@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

comand.CommandText = @"SELECT * FROM [carantin];";

connection.Open();

comand.Connection = connection;

 

adaptor.SelectCommand = comand;

adaptor.Fill(dataset, "0");

int count = dataset.Tables[0].Rows.Count;

SqlDataReader reader = comand.ExecuteReader();

string s1 = "mmm";

if (count > 0)

{

for (int i = 0; i < count; i++)

{

reader.Read();

s1 = reader["ID"].ToString();

 

}

}

 

connection.Close();

string path2;

if (s1=="mmm") path2 = @"d:\temp2\" + (count + 1).ToString() + ".txt";

else path2 = @"d:\temp2\" + (Convert.ToInt32(s1)+1).ToString() + ".txt";

string path1 = listBox1.SelectedItem.ToString();

File.Move(path1, path2);

listBox1.Items.Remove(listBox1.SelectedItem);

if (s1 == "mmm")

InsertAuto(count+ 1, path2, path1);

else

InsertAuto(Convert.ToInt32(s1) + 1,path2, path1);

MessageBox.Show("Сәтті орналастырылды");

}

catch(Exception ex)

{

MessageBox.Show(ex.Message);

}

 

}

 

private void button2_Click(object sender, EventArgs e)

{

SqlConnection connection = new SqlConnection();

SqlCommand comand = new SqlCommand();

SqlDataAdapter adaptor = new SqlDataAdapter();

DataSet dataset = new DataSet();

connection.ConnectionString = (@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

comand.CommandText = @"SELECT * FROM [carantin];";

connection.Open();

comand.Connection = connection;

 

adaptor.SelectCommand = comand;

adaptor.Fill(dataset, "0");

int count = dataset.Tables[0].Rows.Count;

SqlDataReader reader = comand.ExecuteReader();

if (count > 0)

{

for (int i = 0; i < count; i++)

{

reader.Read();

dataGridView1.Rows.Add();

string s1 = reader["FirstPath"].ToString();

dataGridView1[0, dataGridView1.Rows.Count - 1].Value = s1;

}

}

connection.Close();

groupBox1.Visible = true;

}

 

private void button3_Click(object sender, EventArgs e)

{

groupBox1.Visible = false;

dataGridView1.Rows.Clear();

}

 

public void InsertAuto(int ID,string Last, string First)

{

string s = Last;

string s1 = First;

// Оператор SQL

// string sql = string.Format("Insert Into carantin" +

// "(LastPath, FirstPath) Values(@Last, @First)");

SqlConnection connection = new SqlConnection();

SqlCommand comand = new SqlCommand();

SqlDataAdapter adaptor = new SqlDataAdapter();

DataSet dataset = new DataSet();

connection.ConnectionString = (@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

 

{

comand.Parameters.AddWithValue("@ID", ID);

comand.Parameters.AddWithValue("@Last", s);

comand.Parameters.AddWithValue("@First", s1);

}

comand.CommandText = @"Insert Into carantin" + "(ID,LastPath, FirstPath) Values(@ID,@Last, @First)";

 

connection.Open();

comand.Connection = connection;

 

adaptor.SelectCommand = comand;

adaptor.Fill(dataset, "0");

 

connection.Close();

 

 

}

 

private void button9_Click(object sender, EventArgs e)

{

try

{

if (MessageBox.Show("Сіз таңдалған файлды карантиннен шығаруға сенімдісіз бе?", "My Application",

MessageBoxButtons.YesNo, MessageBoxIcon.Question)

== DialogResult.Yes)

{

 

 

string s = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

 

string s1 = "";

SqlConnection connection = new SqlConnection();

SqlCommand comand = new SqlCommand();

SqlDataAdapter adaptor = new SqlDataAdapter();

DataSet dataset = new DataSet();

connection.ConnectionString = (@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

comand.CommandText = @"SELECT * FROM [carantin] WHERE FirstPath='" + s + "';";

connection.Open();

comand.Connection = connection;

 

adaptor.SelectCommand = comand;

adaptor.Fill(dataset, "0");

int count = dataset.Tables[0].Rows.Count;

SqlDataReader reader = comand.ExecuteReader();

if (count > 0)

{

 

reader.Read();

dataGridView1.Rows.Add();

s1 = reader["LastPath"].ToString();

 

}

connection.Close();

 

File.Move(s1, s);

{

System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();

cmd.CommandType = System.Data.CommandType.Text;

 

cmd.CommandText = "DELETE [carantin] WHERE FirstPath='" + s + "';"; cmd.Connection = sqlConnection1;

sqlConnection1.Open();

cmd.ExecuteNonQuery();

sqlConnection1.Close();

dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);

 

}

 

 

MessageBox.Show("Таңдалған файл сәтті қалпына келтірілді");

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

 

private void button8_Click(object sender, EventArgs e)

{

try {

if (MessageBox.Show("Сіз таңдалған файлды жоюға сенімдісіз бе?", "My Application",

MessageBoxButtons.YesNo, MessageBoxIcon.Question)

== DialogResult.Yes)

{

 

 

string s = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

 

string s1 = "";

SqlConnection connection = new SqlConnection();

SqlCommand comand = new SqlCommand();

SqlDataAdapter adaptor = new SqlDataAdapter();

DataSet dataset = new DataSet();

connection.ConnectionString = (@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

comand.CommandText = @"SELECT * FROM [carantin] WHERE FirstPath='" + s + "';";

connection.Open();

comand.Connection = connection;

 

adaptor.SelectCommand = comand;

adaptor.Fill(dataset, "0");

int count = dataset.Tables[0].Rows.Count;

SqlDataReader reader = comand.ExecuteReader();

if (count > 0)

{

 

reader.Read();

dataGridView1.Rows.Add();

s1 = reader["LastPath"].ToString();

 

}

connection.Close();

 

 

File.Delete(s1);

{

System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(@"Data Source=MEIRBEK\SQLEXPRESS;Initial Catalog=antivirus;Integrated Security=True");

System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();

cmd.CommandType = System.Data.CommandType.Text;

 

cmd.CommandText = "DELETE [carantin] WHERE FirstPath='" + s + "';"; cmd.Connection = sqlConnection1;

sqlConnection1.Open();

cmd.ExecuteNonQuery();

sqlConnection1.Close();

dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);

 

}

 

 

MessageBox.Show("Таңдалған файл сәтті жойылды");

}

}

catch(Exception ex)

{

MessageBox.Show(ex.Message);

}

}

#endregion

 

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)

{

 

}

}

}

 






Не нашли, что искали? Воспользуйтесь поиском:

vikidalka.ru - 2015-2024 год. Все права принадлежат их авторам! Нарушение авторских прав | Нарушение персональных данных