示例#1
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();
            }
        }
示例#2
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());
            }
        }
示例#3
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");
                }
            }
        }