private void openProject_Click(object sender, EventArgs e)
{
//打开目录对话框
string strfolderPath = "";
FolderBrowserDialog folderDialog = new FolderBrowserDialog();
if (folderDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
strfolderPath = folderDialog.SelectedPath;
//截取所有文件地址信息
if (strfolderPath.Length > 0)
{
string[] htmlFiles = Directory.GetFiles(strfolderPath, "*.html", SearchOption.AllDirectories);
fileList.BringToFront();
fileList.Items.AddRange(htmlFiles);
this.Controls.Add(fileList);
for (int i = 0; i < fileList.Items.Count; i++)
{
string filePathName = fileList.Items[i].ToString();
//读取单个文件
ReadFile(filePathName);
}
MessageBox.Show("文件检查完毕,检查结果文件存放在e:\\Errorfile.txt");
}
}
C# 打开文件目录并读取整个目录信息
最新推荐文章于 2023-01-15 11:54:33 发布