using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.VisualBasic.Compatibility.VB6; using System.IO; namespace FList { public partial class frmMain : Form { public string[] aMyArray; public string strWhat; public frmMain() { InitializeComponent(); } private void frmMain_Load(object sender, EventArgs e) { this.changeDirPath(ref dirListBox1, ref driveListBox1); this.changeFilePath(ref dirListBox1, ref fileListBox1); lblDirCount.Text = "Directories: " + this.getCount(dirListBox1); lblFileCount.Text = "Files: " + this.getCount(fileListBox1); rdoAll_Click(sender, e); dirListBox1.ContextMenu = contextMenu1; } private void changeDirPath(ref DirListBox dirList, ref DriveListBox driveList) { dirList.Path = driveList.Drive + "\\"; } private void changeFilePath(ref DirListBox dirList, ref FileListBox fileList) { fileList.Path = dirList.Path; } private string getCount(DirListBox dirList) { return (dirList.DirListCount.ToString()); } private string getCount(FileListBox fileList) { return (fileList.Items.Count.ToString()); } private void renameDir(ref DirListBox dirList, string strReplace, string strWith) { if (dirList.Items.Count > 0) { string dirName; foreach (object strItem in dirList.Items) { dirName = strItem.ToString(); dirName = dirName.Replace(strReplace, strWhat); MessageBox.Show(dirName); } //MessageBox.Show(dirList.Items[dirList.SelectedIndex].ToString()); } } private string[] getContents(ref FileListBox fileList) { string[] strArray; strArray = new string[fileList.Items.Count]; if (fileList.Items.Count > 0) { int i = 0; foreach (object strItem in fileList.Items) { strArray[i] = strItem.ToString(); i++; } } return strArray; } private string[] getContents(ref DirListBox dirList) { string[] strArray; strArray = new string[dirList.Items.Count]; if (dirList.Items.Count > 0) { int i = 0; foreach (object strItem in dirList.Items) { strArray[i] = strItem.ToString(); i++; } } return strArray; } private string[] getContents(ref DirListBox dirList, ref FileListBox fileList) { string[] strDirs, strFiles, strAll; strDirs = getContents(ref dirList); strFiles = getContents(ref fileList); strAll = new string[strDirs.Length + strFiles.Length]; int i = 0; if (strDirs.Length > 0) { foreach (string dir in strDirs) { strAll[i] = dir; i++; } } if (strFiles.Length > 0) { foreach (string file in strFiles) { strAll[i] = file; i++; } } return strAll; } private void copyToClipboard(string[] strData) { if (strData.Length > 0) { Clipboard.Clear(); foreach (string strLine in strData) { Clipboard.SetText(Clipboard.GetText() + strLine + "\r\n"); } } } private void dirListBox1_DoubleClick(object sender, EventArgs e) { this.changeFilePath(ref dirListBox1, ref fileListBox1); } private void rdoFolders_Click(object sender, EventArgs e) { aMyArray = getContents(ref dirListBox1); } private void rdoAll_Click(object sender, EventArgs e) { aMyArray = getContents(ref dirListBox1, ref fileListBox1); } private void rdoFiles_Click(object sender, EventArgs e) { aMyArray = getContents(ref fileListBox1); } private void btnCopy_Click(object sender, EventArgs e) { if (rdoFiles.Checked) { rdoFiles_Click(sender, e); } else if (rdoFolders.Checked) { rdoFolders_Click(sender, e); } else { rdoAll_Click(sender, e); } copyToClipboard(aMyArray); } private void driveListBox1_SelectedIndexChanged(object sender, EventArgs e) { } private void ctxtRmUnder_Click(object sender, EventArgs e) { renameDir(ref dirListBox1, "_", " "); } } }