27-03-2013, 02:25 AM
|
#1
|
|
• الانـتـسـاب » Mar 2009
|
• رقـم العـضـويـة » 58256
|
• المشـــاركـات » 1,660
|
• الـدولـة » North Sinai
|
• الـهـوايـة » Writing code, Swimming, Flying
|
• اسـم الـسـيـرفـر » No Server
|
• الـجـنـس » Male
|
• نقـاط التقييم » 13
|
|
|
اكواد برامج سى بلس بلس و سى شارب من برمجتى
بسم الله الرحمن الرحيم
عاملين ايه يا رجاله :D
وحيات ديكى المنتدى وحشنى اوى و الاعضاء الرجاله الى علمونى حجات متتعدش برضو وحشونى :D
بعد غياب طويل قررت ارجع بمواضيع برمجه تانى بس مش فى بى دوت نت علشان باين عليكو مش بتحبوها و كمان بيقولو عليها لغه اطفال -_-
سى شارب و سى بلس بلس :D
اول سورس كود :-
ده حاجه كده علشان تفهم التعامل مع fstream الخاصه ب الملفات
++C
كود PHP:
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
string check;
string rline;
string toread;
cout<<"If you wanna read text press 'R' , wanna write press 'W'\n\n";
cin>>check;
if (check == "R" || "r")
{
ifstream read ("ex.txt");
if ( read.is_open())
{
while ( read.good())
{
getline (read , rline);
cout << endl << rline << endl << endl ;
}
}
}
if ( check =="W" || "w" )
{
cout<<"\n\nWrite Text to save \n\n";
cin >> toread ;
ofstream write ;
write.open("ex.txt");
write << toread ;
cout << "\nSaved ..\n\n";
}
else
{
cout<< "Enter A Valid Value ..";
}
system("PAUSE");
return EXIT_SUCCESS;
}
البرنامج مكتوب على المترجم الجامد ++DEV C
* لو فى مشاكل فى تجربته على الفيجول او تربو سى مش هتخسر حاجه لو قلتلى :D *
تانى سورس كود :-
انتى فايرس بس حاجه خفيفه كده * يعنى مش عاوز حد يقولى انا عندى انتى فايرس هحتاج ده ليه ! .. ده تعلىمى يا حج لو تجارى مكنتش هتشوف السورس لو اتشقلبت :D :D *
كود PHP:
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.VisualBasic;
using System.Windows.Forms;
using Microsoft.CSharp;
using System.Threading;
namespace Softex_Mini_Antivirus
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
button7.Enabled = true;
button8.Enabled = true;
lsf.Text = textBox1.Text;
listBox3.Items.Add(lsf.Text);
progressBar1.Maximum = Convert.ToInt32(listBox1.Items.Count);
totalfiles.Text = Convert.ToString(listBox1.Items.Count);
if (progressBar1.Value != progressBar1.Maximum)
{
try
{
listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
textBox1.Text = listBox1.SelectedItem.ToString();
}
catch (Exception ex)
{
}
try
{
if (!File.Exists(Application.StartupPath + @"/viruslist.txt"))
{
throw new Exception("There's no db file !");
}
TextBox scanbox = new TextBox();
string read = File.ReadAllText(Application.StartupPath + @"/viruslist.txt");
progressBar1.Increment(1);
infecfiles.Text = Convert.ToString(listBox2.Items.Count);
scannedfiles.Text = Convert.ToString(progressBar1.Value);
scanbox.Text = read;
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
FileStream f = new FileStream(listBox1.SelectedItem.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read, 8192);
f = new FileStream(listBox1.SelectedItem.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read, 8192);
md5.ComputeHash(f);
Byte[] hash = md5.Hash;
StringBuilder buff = new StringBuilder();
foreach (Byte hashByte in hash)
{
buff.Append(String.Format("{0:X2}", hashByte));
}
if (scanbox.Text.Contains(buff.ToString()))
{
listBox2.Items.Add(listBox1.SelectedItem);
}
}
catch (Exception ex)
{
}
}
else
{
timer1.Enabled = false;
MessageBox.Show("Finished Scanning Folder!");
tabControl1.SelectTab(3);
}
if (listBox1.Items.Count == 0)
{
MessageBox.Show("No Threats were detected, Scan Window will close!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void timer2_Tick(object sender, EventArgs e)
{
try
{
if (listBox2.Items.Count != 0)
{
listBox2.SelectedIndex += 1;
File.Delete(listBox1.SelectedItem.ToString());
listBox2.Items.Remove(listBox2.SelectedItem.ToString());
}
else
{
timer1.Enabled = false;
timer2.Enabled = false;
MessageBox.Show("Threat Was Removed Successfully!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
}
}
private void fileSystemWatcher1_Changed(object sender, FileSystemEventArgs e)
{
try
{
lsf.Text = e.FullPath;
listBox3.Items.Add(lsf.Text);
openFileDialog1.FileName = "";
TextBox scanbox = new TextBox();
scanbox.Text = File.ReadAllText(Application.StartupPath + @"/viruslist.txt").ToString();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
Byte[] hash = md5.Hash;
StringBuilder buff = new StringBuilder();
foreach (Byte hashByte in hash)
{
buff.Append(String.Format("{0:X2}", hashByte));
}
if (scanbox.Text.Contains(buff.ToString()))
{
openFileDialog1.FileName = e.FullPath;
openFileDialog1.FileName=e.FullPath;
}
}
catch (Exception exception1)
{
MessageBox.Show(exception1.ToString());
Exception ex = exception1;
}
}
private void button6_Click(object sender, EventArgs e)
{
try
{
File.Delete(listBox2.SelectedItem.ToString());
listBox2.Items.Remove(listBox2.SelectedItem.ToString());
MessageBox.Show("Threat Was Removed Successfully!","Info",MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
}
}
private void button5_Click(object sender, EventArgs e)
{
timer2.Enabled = true;
}
private void button1_Click_1(object sender, EventArgs e)
{
folderBrowserDialog1.ShowDialog();
listBox1.Items.Clear();
listBox2.Items.Clear();
tabControl1.SelectTab(1);
try
{
foreach (string strDir in Directory.GetDirectories(folderBrowserDialog1.SelectedPath))
{
foreach (string strFile in Directory.GetFiles(strDir))
{
listBox1.Items.Add(strFile);
}
}
}
catch (Exception ex)
{
}
timer1.Enabled = true;
}
private void button2_Click_1(object sender, EventArgs e)
{
DriveInfo[] mydrive = DriveInfo.GetDrives();
foreach (DriveInfo d in mydrive)
{
try
{
foreach (string strDir in Directory.GetDirectories(d.Name))
{
foreach (string strFile in Directory.GetFiles(strDir))
{
listBox1.Items.Add(strFile);
}
}
}
catch (Exception ex)
{
}
timer1.Enabled = true;
tabControl1.SelectedIndex = 1;
}
}
private void button7_Click(object sender, EventArgs e)
{
timer1.Stop();
progressBar1.Value = 0;
scannedfiles.Text = "<None>";
infecfiles.Text = "<None>";
totalfiles.Text = "<None>";
textBox1.Text = "";
listBox3.Items.Clear();
lsf.Text = "<None>";
listBox2.Items.Clear();
}
private void button8_Click(object sender, EventArgs e)
{
try
{
if (timer1.Enabled == true)
{
timer1.Stop();
button8.Enabled = false;
button9.Enabled = true;
}
else
{
return;
}
}
catch
{
}
}
private void button9_Click(object sender, EventArgs e)
{
try
{
if (timer1.Enabled == false)
{
timer1.Start();
button8.Enabled = true;
button9.Enabled = false;
}
else
{
return;
}
}
catch
{
}
}
private void timer3_Tick(object sender, EventArgs e)
{
if (timer1.Enabled == true)
{
button8.Enabled = true;
button7.Enabled = true;
}
else
{
button8.Enabled = false;
button7.Enabled = false;
}
}
}
}
و بالنسبه لملف viruslist.txt والله مش عارف ارفعه خالص علشان مودم و كده * ملف تكست اها بس 7000 سطر *
انشاء الله لما النت يتعدل هرفعو
عاوز ردود بقى و كده ماشى ؟
مع السلامه :)
|
|
|