Пример #1
0
        /// <summary>
        /// 获取文件夹的文件列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void textBox9_Click(object sender, EventArgs e)
        {
            //richTextBox11.Text = GetAllFiles("C:\\Users\\admi\\Desktop\\新建文件夹", 0);
            //return;
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string selectedPath = dialog.SelectedPath;
                if (!string.IsNullOrWhiteSpace(selectedPath))
                {
                    textBox9.Text = selectedPath;

                    DirectoryInfo di = new DirectoryInfo(selectedPath);

                    string ParentPath = "";
                    string thisFolder = "----文件夹:" + di.Name + "\r\n";
                    if (di.Parent != null)
                    {
                        ParentPath = di.Parent.FullName;
                    }
                    if (cbox2.Checked)
                    {
                        ParentPath = "";
                        thisFolder = "----文件夹:" + di.FullName + "\r\n";
                    }

                    richTextBox11.Text = thisFolder + CommonCode.GetAllFiles(selectedPath, ParentPath, 0);
                }
            }
        }