您的位置:首页 > 编程语言 > C#

C#读取文件夹下面的全部文件的实现

2011-08-16 14:57 309 查看
private void button1_Click(object sender, EventArgs e)  
        {  
            string QQPath;  
            using (RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"Software\Tencent\QQ"))  
            {  
                 QQPath = reg.GetValue("Install").ToString();  
            }  
 
            textBox1.Text = QQPath;  //C#读取文件夹下面的全部文件夹
 
            Get_Folder(QQPath);  
        }  
 
        private void Get_Folder(string FilePath)  
        {  
            if (Directory.Exists(FilePath))  
            {  
                foreach (string d in Directory.GetFileSystemEntries(FilePath))  
                {  
                    if (Directory.Exists(d))  
                    {  
                       listBox1.Items.Add(d.ToString());  
                    }  
                }  //C#读取文件夹下面的全部文件夹
 
            }  
            else 
            {  
                MessageBox.Show("文件夹不存在!");  
            }  
        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: