Example #1
0
 public static void ImportFiles(DirectoryEntry entry)
 {
     OpenFileDialog fileDialog = new OpenFileDialog();
     fileDialog.Multiselect = true;
     if (fileDialog.ShowDialog() == DialogResult.OK) {
         foreach (String file in fileDialog.FileNames)
         {
             if (entry.GetEntries().Any(e => e.Name == Path.GetFileName(file)))
             {
                 // TODO: Ask for overwrite
                 MessageBox.Show(String.Format("Error: file {0} already exists.", Path.GetFileName(file)));
                 return;
             }
         }
         foreach (String file in fileDialog.FileNames)
         {
             // TODO: add resources, decide if to compress or not, all by extentions.
             // Right now all regular files compressed by default
             RegularFileEntry addedFile = new RegularFileEntry(Path.GetFileName(file), new ExternalFileStreamCreator(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)), true);
             entry.AddEntry(addedFile);
             if (entry.FilesListView != null)
             {
                 entry.FilesListView.Items.Add(new EntryListViewItem(addedFile));
             }
         }
     }
 }
Example #2
0
 public static void NewFolder(DirectoryEntry entry)
 {
     string name = "New Folder";
     int i = 1;
     for (; entry.GetEntries().Any(e => e.Name == name); ++i, name = String.Format("New Folder ({0})", i)) ;
     DirectoryEntry addedFolder = new DirectoryEntry(name, new List<Entry>());
     entry.AddEntry(addedFolder);
     entry.Node.Nodes.Add(new EntryTreeNode(addedFolder, new EntryTreeNode[]{}));
     if (!entry.Node.IsExpanded)
     {
         entry.Node.Expand();
     }
     addedFolder.Node.TreeView.SelectedNode = addedFolder.Node;
     addedFolder.Node.TreeView.LabelEdit = true;
     addedFolder.Node.BeginEdit();
 }