private void BntCreateSubFolder_Click(object sender, EventArgs e) { TreeNode newSelected = TreeView1.SelectedNode; DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag; string LabelTxt = "Enter new sub-folder name."; string NewFolderName; string OldFileName = ""; FrmFileFolderDialog subfolder; subfolder = new FrmFileFolderDialog(OldFileName, LabelTxt) { Text = "Create a new sub-folder" }; subfolder.ShowDialog(); NewFolderName = subfolder.NFileOrFolderName; string NewFolderFullName = Path.Combine(nodeDirInfo.FullName, NewFolderName); if (subfolder.BntOKClicked) { if (!Directory.Exists(NewFolderFullName)) { DirectoryInfo subFolderInfo = nodeDirInfo.CreateSubdirectory(NewFolderName); } else { MessageBox.Show("Directory '" + NewFolderName + "' already exist!", "Duplicate Directory Name", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void BntRename_Click(object sender, EventArgs e) { try { TreeNode newSelected = TreeView1.SelectedNode; DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag; string OldFileName = ListView1.SelectedItems[0].Text; string NewFileName; string LabelTxt = "Enter the new file name"; string Ext = Path.GetExtension(OldFileName); string OldFullPath = Path.Combine(nodeDirInfo.FullName, OldFileName); FrmFileFolderDialog rename; rename = new FrmFileFolderDialog(OldFileName, LabelTxt) { Text = "Rename File" }; rename.ShowDialog(); if (rename.BntOKClicked) { NewFileName = rename.NFileOrFolderName; string NewFullPath = Path.Combine(nodeDirInfo.FullName, NewFileName + Ext); if (OldFullPath == NewFullPath) { MessageBox.Show("File " + NewFileName + " already exists in this folder!", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error); rename.Close(); } else { File.Move(OldFullPath, NewFullPath); } PopulateListView(newSelected); } } catch (Exception ex) { MessageBox.Show(ex.Message); } Reset = 0; }
private void OpenNewFile(string Ext) { TreeNode newSelected = TreeView1.SelectedNode; DirectoryInfo DirectoryName = (DirectoryInfo)newSelected.Tag; bool BntOk = false; string Label = "Enter the new file name"; string NewFileName = ""; string OldFileName = ""; if (Ext == ".htm") { FrmFileFolderDialog newHtmlFile; newHtmlFile = new FrmFileFolderDialog(OldFileName, Label) { Text = "New Html File" }; newHtmlFile.ShowDialog(); BntOk = newHtmlFile.BntOKClicked; NewFileName = newHtmlFile.NFileOrFolderName; OpenEdit(BntOk, DirectoryName, NewFileName, Ext); PopulateListView(newSelected); } else { FrmFileFolderDialog newTextFile; newTextFile = new FrmFileFolderDialog(OldFileName, Label) { Text = "New Text File" }; newTextFile.ShowDialog(); BntOk = newTextFile.BntOKClicked; NewFileName = newTextFile.NFileOrFolderName; OpenEdit(BntOk, DirectoryName, NewFileName, Ext); PopulateListView(newSelected); } Reset = 0; }