public static void Paste(string directory) { //FilenamePhotoProvider fpp = new FilenamePhotoProvider(); string [] filedst = new String[nbFile]; for (int n = 0; n < nbFile; n++) { char [] separator = new char[1]; separator[0]='_'; string [] liststr = file[n].Split(separator); if (liststr.Length == 2) { FilenamePhotoProvider fpp = new FilenamePhotoProvider(liststr[0]); List<String> result = fpp.getPossibleFilename(directory, 1); filedst[n] = result[0]; } else { FileInfo fi = new FileInfo(file[n]); filedst[n] = DirUtil.JoinDirAndFile(directory ,fi.Name); } } ShellFileOperation sfo = new ShellFileOperation(); sfo.SourceFiles = file; sfo.DestFiles = filedst; if (_copy) { sfo.Operation = ShellFileOperation.FileOperations.FO_COPY; sfo.ProgressTitle="Copy"; } if (_cut) { sfo.Operation = ShellFileOperation.FileOperations.FO_MOVE; sfo.ProgressTitle = "Move"; } sfo.DoOperation(); }
private void imageListView1_DropFiles(object sender, DropFileEventArgs e) { if (treeView1.SelectedNode.GetType().Name == "NodeCategory") { NodeCategory nCat = (NodeCategory)treeView1.SelectedNode; if (nCat.IsLeaf() == false) { MessageBox.Show("You can't drop on a category with child "); e.Cancel = true; return; } FChoosePhotographer choosePhotographer = new FChoosePhotographer(nodephotographer); if (choosePhotographer.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FilenamePhotoProvider fpp = new FilenamePhotoProvider(choosePhotographer.Photographe); ImageListView.ImageListViewSelectedItemCollection selected = imageListView1.SelectedItems; String DirectoryDst = nCat.getDirectory(); List<string> Lfile = fpp.getPossibleFilename(DirectoryDst, e.FileNames.Length); string[] fileDst = new String[Lfile.Count]; int n = 0; foreach (String s in Lfile) { fileDst[n] = s; n++; } this.Cursor = Cursors.WaitCursor; ShellFileOperation sfo = new ShellFileOperation(); sfo.Operation = ShellFileOperation.FileOperations.FO_COPY; sfo.OwnerWindow = this.Handle; sfo.SourceFiles = e.FileNames; sfo.DestFiles =fileDst; sfo.ProgressTitle = "Import..."; sfo.DoOperation(); toolStripProgressBarThumb.Visible = true; toolStripProgressBarThumb.Minimum = 0; toolStripProgressBarThumb.Maximum = sfo.DestFiles.Length; ThumbMaker tm = new ThumbMaker(); tm.processFiles(sfo.DestFiles, DirectoryDst + "\\miniatures\\", delegate(int f, string m) { if (f == -1) { toolStripStatusLabel1.Text = m; } else { toolStripStatusLabel1.Text = " Processing thumbnail File " + f.ToString(); toolStripProgressBarThumb.Value = f; if (toolStripProgressBarThumb.Maximum-1 == f) { tabControl1.SelectedIndex = 0; try { PopulateListView(new DirectoryInfo(nCat.getDirectory())); } catch (Exception exp) { MessageBox.Show("Error in category " + exp.Message); } FillGuiCategory(nCat); //TreeNode node = (TreeNode)nodeCategory; //ExpandNode(nodeCategory, node); //nodeCategory.Expand(); } } }); this.Cursor = Cursors.Arrow; toolStripProgressBarThumb.Visible = false; } else { MessageBox.Show("Error Happen in the wizard configuration please try again "); } } e.Cancel = true; }