private void NewDirectoryButton_Click(object sender, EventArgs e) { ActiveControl = null; string newDirName = InputBox.Show("Directory name:"); if (newDirName == null) { return; } _curDirectory.NewDirectory(newDirName); _curDirectory.Commit(); PopulateExplorerList(_curDirectory); PopulateExplorerTree(); }
// Requires caller to commit changes to parent private void AddContents(BobFsNode parent, string path) { if (File.Exists(path)) { BobFsNode newFile = parent.NewFile(Path.GetFileName(path)); byte[] fileContents = File.ReadAllBytes(path); newFile.WriteAll(0, fileContents, 0, fileContents.Length); newFile.Commit(); } else if (Directory.Exists(path)) { BobFsNode newDir = parent.NewDirectory(Path.GetFileName(path)); foreach (string dirEntry in Directory.EnumerateFileSystemEntries(path)) { AddContents(newDir, dirEntry); } newDir.Commit(); } }