コード例 #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
                    {
                        FolderMethods.CopyDir(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text), FileMethods.Combine(s, view.getsetListView.SelectedItems[0].Text));
                    }
                }
                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
ファイル: Entity.cs プロジェクト: Svetuf/FileManager
        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");
                }
            }
        }