示例#1
0
        private void MoveInThread()
        {
            //string destinationPath = "";

            string cbToCopyText = "";

            this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate()
            {
                cbToCopyText = cbToCopy.Text;
                //MessageBox.Show(cbToCopyText);
                //lvFromCopy.SelectedItem = fsi;
                this.Hide();
            });

            while (string.IsNullOrEmpty(cbToCopyText))
            {
                Thread.Sleep(10);
            }

            FileManager fm = new FileManager();
            fm.Move(lstCopyFiles, new DirectoryInfo(copyPath));

            //foreach (var fsi in lvFromCopy.Items)
            //{

            //    //this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate()
            //    //{
            //    //    cbToCopyText = cbToCopy.Text;

            //    //    lvFromCopy.SelectedItem = fsi;
            //    //    this.Hide();
            //    //});

            //    if (fsi.GetType() == typeof(DirectoryInfo))
            //    {
            //        DirectoryInfo di = (DirectoryInfo)fsi;
            //        destinationPath = cbToCopyText + System.IO.Path.DirectorySeparatorChar + di.Name;
            //        switch (Properties.Settings.Default.FileOverwriteOption)
            //        {
            //            case FileOverwriteOptionKind.ShowDialog:
            //                FileSystem.MoveDirectory(di.FullName, destinationPath,
            //                    UIOption.AllDialogs, UICancelOption.DoNothing);
            //                break;
            //            case FileOverwriteOptionKind.Skip:
            //                FileSystem.MoveDirectory(di.FullName, destinationPath, false);
            //                break;
            //            case FileOverwriteOptionKind.Rewrite:
            //                FileSystem.MoveDirectory(di.FullName, destinationPath, true);
            //                break;
            //            default:
            //                break;
            //        }
            //    }
            //    else if (fsi.GetType() == typeof(FileInfo))
            //    {
            //        FileInfo fi = (FileInfo)fsi;
            //        destinationPath = cbToCopyText + System.IO.Path.DirectorySeparatorChar + fi.Name;
            //        switch (Properties.Settings.Default.FileOverwriteOption)
            //        {
            //            case FileOverwriteOptionKind.ShowDialog:
            //                FileSystem.MoveFile(fi.FullName, destinationPath,
            //                    UIOption.AllDialogs, UICancelOption.DoNothing);
            //                break;
            //            case FileOverwriteOptionKind.Skip:
            //                FileSystem.MoveFile(fi.FullName, destinationPath, false);
            //                break;
            //            case FileOverwriteOptionKind.Rewrite:
            //                FileSystem.MoveFile(fi.FullName, destinationPath, true);
            //                break;
            //            default:
            //                break;
            //        }
            //    }

            //}

            Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate()
            {
                this.Close();
            });
        }
示例#2
0
        private void Delete(bool toRecycle)
        {
            FileManager fm = new FileManager();

            if (toRecycle)
            {
                fm.DeleteToRecycler(deleteFSIList);
            }
            else
            {
                fm.Delete(deleteFSIList);
            }

            //RecycleOption roToRecycle = RecycleOption.SendToRecycleBin;

            //if (!toRecycle)
            //{
            //    roToRecycle = RecycleOption.DeletePermanently;
            //}

            //foreach(var fsi in deleteFSIList)
            //{
            //    lvMain.SelectedItem = fsi;

            //    if (fsi.GetType() == typeof(DirectoryInfo))
            //    {
            //        FileSystem.DeleteDirectory(fsi.FullName, UIOption.OnlyErrorDialogs, roToRecycle);
            //    }
            //    else if (fsi.GetType() == typeof(FileInfo))
            //    {
            //        FileSystem.DeleteFile(fsi.FullName, UIOption.OnlyErrorDialogs, roToRecycle);
            //    }
            //    else
            //    {
            //        throw new Exception("Uncnoun type");
            //    }
            //}
        }