发布网友 发布时间:2024-10-23 23:06
共1个回答
热心网友 时间:2024-10-24 00:52
你问过一次了?
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());
}
}
}