1个回答
展开全部
你问过一次了?
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());
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询