C# 搜索指定文件夹中的文件夹及文件夹中文件,列出子文件夹名和该文件夹下首个和末个文件名、创建时间
详情如下链接:http://club.excelhome.net/thread-622545-1-1.html...
详情如下链接:http://club.excelhome.net/thread-622545-1-1.html
展开
展开全部
你问过一次了?
private void button1_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog fbd = new FolderBrowserDialog())
{
fbd.Description = "选择要读取文件的目录";
fbd.ShowNewFolderButton = false;
if (fbd.ShowDialog(this) == DialogResult.OK)
{
System.Text.StringBuilder files = new System.Text.StringBuilder();
DirectoryInfo di = new DirectoryInfo(fbd.SelectedPath);
foreach (FileInfo fi in di.GetFiles("*.txt"))
{
//Thread t = new Thread(this.InvokeThread);
//t.Start(fi.FullName);
files.AppendLine("文件名:" + fi.Name + ";文件大小:" + fi.Length.ToString() + ";创建时间:" + fi.CreationTime.ToString() + ";最后访问时间:" + fi.LastAccessTime.ToString());
}
MessageBox.Show(files.ToString());
}
}
}
private void button1_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog fbd = new FolderBrowserDialog())
{
fbd.Description = "选择要读取文件的目录";
fbd.ShowNewFolderButton = false;
if (fbd.ShowDialog(this) == DialogResult.OK)
{
System.Text.StringBuilder files = new System.Text.StringBuilder();
DirectoryInfo di = new DirectoryInfo(fbd.SelectedPath);
foreach (FileInfo fi in di.GetFiles("*.txt"))
{
//Thread t = new Thread(this.InvokeThread);
//t.Start(fi.FullName);
files.AppendLine("文件名:" + fi.Name + ";文件大小:" + fi.Length.ToString() + ";创建时间:" + fi.CreationTime.ToString() + ";最后访问时间:" + fi.LastAccessTime.ToString());
}
MessageBox.Show(files.ToString());
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询