Example #1
0
        private void updateTheMenu(object sender, EventArgs e)
        {
            if (view.getsetFi == "" || view.getsetFi.Length <= 2)
            {
                view.getsetListView.Items.Clear();
                var drives = FolderMethods.getDrInfo();
                foreach (var i in drives)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.ImageIndex = 2;
                    lvi.Text       = i.Name;
                    lvi.Tag        = "directory";
                    view.getsetListView.Items.Add(lvi);
                }
                view.obnullFi();
                view.getsetRichTextBox1("DISKS");
                view.getWatcher.Path   = @"\";
                view.getWatcher.Filter = "*.*";
                return;
            }
            try
            {
                if (view.getsetFi.Contains(".zip"))
                {
                    foldrrrr = new ZippedFolder(view.getsetFi);
                    List <string> asss = new List <string>();
                    try
                    {
                        asss = foldrrrr.GetAllFiles();
                    }
                    catch (Exception e1)
                    {
                    }
                    view.getsetListView.Clear();

                    foreach (string i in asss)
                    {
                        ListViewItem lvi = new ListViewItem();
                        lvi.ImageIndex = 3;
                        lvi.Text       = i;
                        lvi.Tag        = "file";
                        view.getsetListView.Items.Add(lvi);
                    }
                    return;
                }

                view.getsetListView.Items.Clear();

                FolderMethods.UpdateDirectories(view.getsetListView.Items, view.getsetFi);
                FileMethods.UpdateFiles(view.getsetListView.Items, view.getsetFi);

                view.getsetRichTextBox1(view.getsetFi);
                view.getWatcher.Path   = view.getsetFi;
                view.getWatcher.Filter = "*.*";
            }
            catch (Exception) { }
        }
Example #2
0
        public void Visit(FolderMethods f)
        {
            FileMethods[] mas = FolderMethods.myfilesEntity(f.GetMyName());

            foreach (FileMethods i in mas)
            {
                Visit(i);
            }
        }
Example #3
0
 private void MENU10(object sender, EventArgs e)
 {
     if (view.getsetListView.SelectedItems[0].Tag.ToString() == "file")
     {
         FileMethods m = new FileMethods(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
         m.Accept(visitor);
     }
     else
     {
         FolderMethods m = new FolderMethods(FolderMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
         m.Accept(visitor);
     }
 }
Example #4
0
        public void Visit(FolderMethods f)
        {
            FileMethods[] mas  = FolderMethods.myfilesEntity(f.GetMyName());
            string        dano = "";

            foreach (FileMethods i in mas)
            {
                dano += i.getMytTxt();
            }

            string hashed = MD5.CreateMD5(dano);

            MessageBox.Show(hashed);
        }
Example #5
0
        public static void CopyDir(string FromDir, string ToDir)
        {
            FolderMethods.CreateDirectory(ToDir);

            foreach (string s1 in new FolderMethods(FromDir).Get_Files_In_Selected_Folder())
            {
                string s2 = ToDir + "\\" + new FolderMethods(s1.ToString()).GetNameWithoutPath();
                FileMethods.copy(s1, s2, true);
            }
            foreach (string s in FolderMethods.GetDirectories(FromDir))
            {
                CopyDir(s, ToDir + "\\" + new FolderMethods(s.ToString()).GetNameWithoutPath());
            }
        }
Example #6
0
        protected void OnkoZakrito(string s, string dela)
        {
            if (dela == "copy")
            {
                try
                {
                    if (view.getsetListView.SelectedItems[0].Tag.ToString() == "file")
                    {
                        FileMethods.copy(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text), FileMethods.Combine(s, view.getsetListView.SelectedItems[0].Text), true);
                    }
                    else
                    {
                        // directory
                    }
                }
                catch (Exception e)
                {
                }
                return;
            }
            if (dela == "replace")
            {
                if (view.getsetListView.SelectedItems[0].Tag.ToString() == "file")
                {
                    FileMethods.move(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text), FileMethods.Combine(s, view.getsetListView.SelectedItems[0].Text));
                }
                else
                {
                    FolderMethods.move(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text), s);
                }
                return;
            }

            if (dela == "rename")
            {
                if (view.getsetListView.SelectedItems[0].Tag.ToString() == "directory")
                {
                    FolderMethods.move(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text),
                                       FileMethods.Combine(view.getsetFi, s));
                    view.renewList();
                    return;
                }
                FileMethods.delete(FileMethods.Combine(view.getsetFi, s));
                string h   = view.getsetListView.SelectedItems[0].Text;
                int    ind = h.IndexOf('.');
                h = h.Substring(ind);
                FileMethods.move(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text), FileMethods.Combine(view.getsetFi, s + h));
                view.renewList();
            }
        }
Example #7
0
 private void decryptClickedRealize(object sender, EventArgs e)
 {
     if (view.getsetListView.SelectedItems.Count > 0)
     {
         if (view.getsetListView.SelectedItems[0].Tag.ToString() == "file")
         {
             FileMethods m = new FileMethods(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
             CesarEncrypt.setKey(int.Parse(view.getsetEncryptTExtBox));
             m.Accept(CesarEncrypt);
         }
         else
         {
             FolderMethods m = new FolderMethods(FolderMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
             CesarEncrypt.setKey(int.Parse(view.getsetEncryptTExtBox));
             m.Accept(CesarEncrypt);
         }
     }
 }
Example #8
0
        public void InsertZipToDir(string newway)
        {
            try
            {
                FolderMethods.DeleteDirectory("ExtractData");
            }
            catch { }
            FolderMethods.CreateDirectory("ExtractData");

            int    ZipPlace   = path.IndexOf(".archive.zip\\");
            string ArchiveWay = path.Substring(ZipPlace + 13);
            string path1      = path.Substring(0, ZipPlace + 12);

            using (ZipFile zip = ZipFile.Read(path1))
            {
                if (path[path.Length - 1] == '/')
                {
                    ArchiveWay = ArchiveWay.Remove(ArchiveWay.Length - 1, 1) + "\\";
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName.Contains(ArchiveWay.Replace('\\', '/')) && e.FileName.IndexOf(ArchiveWay.Replace('\\', '/')) == 0)
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }
                    FolderMethods.CopyDir("ExtractData\\" + ArchiveWay, newway + '\\' + ArchiveWay);

                    FolderMethods.DeleteDirectory("ExtractData");
                }
                else
                {
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName == ArchiveWay.Replace('\\', '/'))
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }

                    FileMethods.copy("ExtractData\\" + ArchiveWay, newway, false);
                    FolderMethods.DeleteDirectory("ExtractData");
                }
            }
        }
Example #9
0
 private void MENU2(object sender, EventArgs e)
 {
     if (view.getsetFi.Contains(".zip"))
     {
         new ZippedFile(view.getsetFi).Delete(view.getsetListView.SelectedItems[0].Text);
     }
     else
     {
         if (view.getsetListView.SelectedItems[0].Tag.ToString() == "file")
         {
             FileMethods.delete(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
         }
         else
         {
             FolderMethods.DeleteDirectory(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
         }
     }
     view.renewList();
 }
Example #10
0
        public Form1()
        {
            w = new FileSystemWatcher();
            InitializeComponent();

            Presenter pres = new Presenter(this);


            visitor      = new Md5Hash();
            CesarCrypt   = new crypt();
            CesarEncrypt = new encrypt();

            asyncArch   = new asyncTaskZip();
            taskArch    = new taskZip();
            foreachArch = new foreachZip();
            regArch     = new regularZip();

            s = new Strategy(new defaultSearch());

            fi = new WorkWithFiles();
            ImageList imageListSmall = new ImageList();

            imageListSmall.Dispose();
            imageListSmall.Images.Add(Bitmap.FromFile("C:\\file.ico"));
            imageListSmall.Images.Add(Bitmap.FromFile("C:\\papka.ico"));
            imageListSmall.Images.Add(Bitmap.FromFile("C:\\intro-external-drive.png"));
            imageListSmall.Images.Add(Bitmap.FromFile("C:\\zip.png"));
            imageListSmall.ImageSize = new Size(32, 32);
            listView1.LargeImageList = imageListSmall;
            var drives = FolderMethods.getDrInfo();

            foreach (var i in drives)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.ImageIndex = 2;
                lvi.Text       = i.Name;
                lvi.Tag        = "directory";
                listView1.Items.Add(lvi);
            }
            contextMenu = new System.Windows.Forms.ContextMenu();
            menuItem1   = new MenuItem("&Copy", new EventHandler(menu1_click));
            menuItem2   = new MenuItem("&Cut", new EventHandler(menu3_click));
            menuItem3   = new MenuItem("&Delete", new EventHandler(menu2_click));
            menuItem4   = new MenuItem("&Rename", new EventHandler(menu4_click));
            menuItem5   = new MenuItem("&Archive", new EventHandler(menu5_click));
            menuItem6   = new MenuItem("&Archive parralelfreach", new EventHandler(menu6_click));
            menuItem7   = new MenuItem("&Archive parralelTask", new EventHandler(menu7_click));
            menuItem8   = new MenuItem("&Archive Task async", new EventHandler(menu8_click));
            menuItem9   = new MenuItem("&Statictic", new EventHandler(menu9_click));
            menuItem10  = new MenuItem("&MD5 hash", new EventHandler(menu10_click));
            contextMenu.MenuItems.Add(menuItem1);
            contextMenu.MenuItems.Add(menuItem2);
            contextMenu.MenuItems.Add(menuItem3);
            contextMenu.MenuItems.Add(menuItem4);
            contextMenu.MenuItems.Add(menuItem5);
            contextMenu.MenuItems.Add(menuItem6);
            contextMenu.MenuItems.Add(menuItem7);
            contextMenu.MenuItems.Add(menuItem8);
            contextMenu.MenuItems.Add(menuItem9);
            contextMenu.MenuItems.Add(menuItem10);
            richTextBox2.Text = "eat";
        }
Example #11
0
 public override void createFolder()
 {
     FolderMethods.CreateDirectory(path + "\\newfolder");
 }
Example #12
0
        public void InsertZipToZip(string newWay)
        {
            int    ZipPlace   = path.IndexOf(".archive.zip\\");
            string ArchiveWay = path.Substring(ZipPlace + 13);
            string path1      = path.Substring(0, ZipPlace + 12);

            try
            {
                FolderMethods.DeleteDirectory("ExtractData");
            }
            catch { }
            FolderMethods.CreateDirectory("ExtractData");
            int    newZipPlace   = newWay.IndexOf(".archive.zip");
            string newArchiveWay = newWay.Substring(newZipPlace);
            string newpath       = newWay.Substring(0, newZipPlace + 12);

            if (ArchiveWay[ArchiveWay.Length - 1] == '/')
            {
                ArchiveWay = ArchiveWay.Remove(ArchiveWay.Length - 1, 1) + "\\";
                if (newArchiveWay != "")
                {
                    newArchiveWay = newArchiveWay.Remove(newArchiveWay.Length - 1, 1) + "\\";
                }
                else
                {
                    newArchiveWay = "\\";
                }
                using (ZipFile zip = ZipFile.Read(path1))
                {
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName.Contains(ArchiveWay.Replace('\\', '/')) && e.FileName.IndexOf(ArchiveWay.Replace('\\', '/')) == 0)
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }
                }
            }
            else
            {
                using (ZipFile zip = ZipFile.Read(path))
                {
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName == ArchiveWay.Replace('\\', '/'))
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }
                }
            }

            while (newArchiveWay[newArchiveWay.Length - 1] != '\\')
            {
                newArchiveWay = newArchiveWay.Remove(newArchiveWay.Length - 1, 1);
            }
            using (ZipFile newzip = ZipFile.Read(newpath))
            {
                newzip.AddItem("ExtractData\\" + ArchiveWay, ArchiveWay.Replace('\\', '/'));
                newzip.Save();
            }
            FolderMethods.DeleteDirectory("ExtractData");
        }