c#程序显示所选目录及其子目录内所有文件
来源:百度文库 编辑:神马文学网 时间:2024/04/28 06:35:31
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace formTest
{
public partial class Form3 : Form
{
SCItemSet itemSet = new SCItemSet();
public Form3()
{
InitializeComponent();
}
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new Form3());
}
private void btnBrowse_Click(object sender, EventArgs e)
{
FolderBrowserDialog browse = new FolderBrowserDialog();
browse.ShowDialog();
txtShowPath.Text = browse.SelectedPath;
}
private void detail_Click(object sender, EventArgs e)
{
txtShowDetail.Text = string.Empty;
string ShowInfo="";
//string ShowPath = txtShowPath.Text.ToString().Replace("\\", @"\");
getDirFiles(txtShowPath.Text);
for(int i=0;i {
ShowInfo += itemSet[i].Name+"\r\n";
}
txtShowDetail.Text = ShowInfo.ToString();
}
public void getDirFiles(string strPaths)
{
DirectoryInfo d = new DirectoryInfo(strPaths);
DirectoryInfo[] dis = d.GetDirectories();
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
SCItem item = new SCItem();
item.Name = fi.Name;
itemSet.Add(item);
}
string strPath;
foreach (DirectoryInfo di in dis)
{
strPath=strPaths+"\\"+di.Name;
getDirFiles(strPath);
}
} }
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace formTest
{
public partial class Form3 : Form
{
SCItemSet itemSet = new SCItemSet();
public Form3()
{
InitializeComponent();
}
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new Form3());
}
private void btnBrowse_Click(object sender, EventArgs e)
{
FolderBrowserDialog browse = new FolderBrowserDialog();
browse.ShowDialog();
txtShowPath.Text = browse.SelectedPath;
}
private void detail_Click(object sender, EventArgs e)
{
txtShowDetail.Text = string.Empty;
string ShowInfo="";
//string ShowPath = txtShowPath.Text.ToString().Replace("\\", @"\");
getDirFiles(txtShowPath.Text);
for(int i=0;i
ShowInfo += itemSet[i].Name+"\r\n";
}
txtShowDetail.Text = ShowInfo.ToString();
}
public void getDirFiles(string strPaths)
{
DirectoryInfo d = new DirectoryInfo(strPaths);
DirectoryInfo[] dis = d.GetDirectories();
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
SCItem item = new SCItem();
item.Name = fi.Name;
itemSet.Add(item);
}
string strPath;
foreach (DirectoryInfo di in dis)
{
strPath=strPaths+"\\"+di.Name;
getDirFiles(strPath);
}
} }
}
c#程序显示所选目录及其子目录内所有文件
学习 c#程序显示所选目录及其子目录内所有文件
学习 c#程序显示所选目录及其子目录内所有文件 - acefly的专栏 - CSDNBlog
C#文件和目录 - "飞"娥 - 博客园
C#中获取文件路径、DataGridView显示行号
用SendMessage获取目录下所有文件
用SendMessage获取目录下所有文件
自动清空站点目录下所有文件
QQ所有文件和目录的作用解释和分析
文件夹选项—查看,显示所有文件,无法修改?
C# 清理Temp文件实例代码-程序开发-红黑联盟
C#程序调用非托管C++ DLL文件的方法 - Chase的技术博客 - 博客园
如何列出文件夹及其所有子文件夹中的文件?
C# 操作INI文件
C# 操作INI文件
C#文件操作
如何用WindowsAPI函数遍历指定驱动器、目录的所有文件
"文件夹选项"里“显示所有文件和文件夹”无效的解决方法
显示隐藏文件可显示?
7279键盘显示程序
如何 提取文件目录
WINDOWS系统文件目录
如何 提取文件目录
如何显示隐藏文件?