private void listView2_DragDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
         foreach (var file in files)
         {
             if (File.Exists(file))
             {
                 File.Copy(file, label2.Text);
             }
             else if (Directory.Exists(file))
             {
                 DirMethods.CopyDirectory(new DirectoryInfo(file), new DirectoryInfo(label2.Text));
             }
         }
     }
     else if (e.Data.GetDataPresent(DataFormats.Text))
     {
         if (File.Exists(e.Data.GetData(DataFormats.Text) as string))
         {
             File.Copy(e.Data.GetData(DataFormats.Text) as string, label2.Text);
         }
         else if (Directory.Exists(e.Data.GetData(DataFormats.Text) as string))
         {
             DirMethods.CopyDirectory(new DirectoryInfo(e.Data.GetData(DataFormats.Text) as string), new DirectoryInfo(label2.Text));
         }
     }
 }
        public static void Paste(ListView listView, string path)
        {
            DirectoryInfo tmp = new DirectoryInfo(path);

            if (tmp.Exists)
            {
                foreach (var item in Clipboard.GetFileDropList())
                {
                    FileInfo file = new FileInfo(item);
                    if (file.Exists)
                    {
                        File.Copy(item, tmp.FullName + "\\" + file.Name);
                    }

                    DirectoryInfo dir = new DirectoryInfo(item);
                    if (dir.Exists)
                    {
                        DirMethods.CopyDirectory(dir, tmp);
                    }
                }
            }
            else
            {
                MessageBox.Show("Direcotry not exists.");
            }
        }
예제 #3
0
 private void SetFolderLength(object dir)
 {
     try
     {
         label6.Text = DirMethods.DirectoryLength(dir as DirectoryInfo).ToString() + " байт";
     } catch (Exception e)
     {
         MessageBox.Show(e.Message);
         label6.Text = "Ошибка вычисления.";
     }
 }