我试图将子文件夹名而不是 FULLNAME 放入我的数据表中的单独列中。请帮忙。
protected void Page_Load(object sender, EventArgs e) {
DataTable ReportsDT = new DataTable("ReportsDT");
ReportsDT.Columns.Add("Name");
ReportsDT.Columns.Add("FolderName");
DirectoryInfo DirInfo = new DirectoryInfo(Server.MapPath("Reports"));
DataRow ReportDTRow = ReportsDT.NewRow();
foreach (FileInfo fi in DirInfo.GetFiles("*.*", SearchOption.AllDirectories)) {
ReportDTRow = ReportsDT.NewRow();
ReportDTRow["Name"] = fi.Name;
ReportDTRow["FolderName"] = fi.FullName;
ReportsDT.Rows.Add(ReportDTRow);
}
}