Example #1
0
        public async void Update(ISubject subject)
        {
            string line;

            if ((subject as FileWatcher).BoolPath_Create)
            {
                line = String.Format("FileWatcher: Обнаружен новый файл, передаю его сканеру:{0}", (subject as FileWatcher).FullPath_Create.ToString());
                Program.fm1.Filewatcher_listbox(line);

                ScanEngine wf    = new ScanEngine();
                bool       virus = false;
                virus = wf.scan_String((subject as FileWatcher).Put, (subject as FileWatcher).FullPath_Create.ToString());

                if (virus)
                {
                    line = String.Format("FileWatcher: Новый файл является вирусом! {0}", (subject as FileWatcher).FullPath_Create.ToString());
                    Program.fm1.Filewatcher_listbox(line);
                }
                else
                {
                    line = String.Format("FileWatcher: Обнаруженный файл не является вирусом {0}", (subject as FileWatcher).FullPath_Create.ToString());
                    Program.fm1.Filewatcher_listbox(line);
                }
            }

            if ((subject as FileWatcher).BoolPath_Deleted)
            {
                line = String.Format("FileWatcher: Удален файл! {0}", (subject as FileWatcher).FullPath_Deleted.ToString());
                Program.fm1.Filewatcher_listbox(line);
            }
        }
Example #2
0
        void DragAndDrop_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            List <string>    paths = new List <string>();
            ScanEngine       Seng  = new ScanEngine();
            Preparation_scan pr    = new Preparation_scan();

            foreach (string obj in (string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop))
            {
                if (Directory.Exists(obj))
                {
                    bw         = new BackgroundWorker();
                    bw.DoWork += (obj2, ea) => Potok3(obj, paths, Seng, pr);
                    bw.RunWorkerAsync();
                }
                else
                {
                    string file_no_raz = (Path.GetDirectoryName(obj) + @"\" + Path.GetFileNameWithoutExtension(obj) + ".zip");
                    if (file_no_raz == obj)
                    {
                        bw2         = new BackgroundWorker();
                        bw2.DoWork += (obj2, ea) => Potok4(obj);
                        bw2.RunWorkerAsync();
                        continue;
                    }

                    if (Seng.scan_String(Path.GetDirectoryName(obj), obj))
                    {
                        //string line = String.Format("Файл является вирусом! {0}", obj);
                        scan_listBox.Items.Add("Файл является вирусом!");
                        scan_listBox.Items.Add(obj);
                    }
                    else
                    {
                        string line = String.Format("Файл не является вирусом {0}", obj);
                        scan_listBox.Items.Add(line);
                    }
                }
            }
        }