private void NewFileButton_Click(object sender, EventArgs e) { ActiveControl = null; string newFileName = InputBox.Show("File name:"); if (newFileName == null) { return; } _curDirectory.NewFile(newFileName); _curDirectory.Commit(); PopulateExplorerList(_curDirectory); }
// 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(); } }