我不能只给你写所有的代码......但我会给你一个启动代码:
int scanLVL = 4;//or however deep you need to go...
public void GetImageFromDir(string sourceDir, int startLVL)
{
if (startLVL <= scanLVL)
{
// Here you can process files found in the directory.
string[] fileEntries = Directory.GetFiles(sourceDir);
Label_showdata.Text +="<br />Dir:" + Path.GetFileName(sourceDir) ;
foreach (string fileName in fileEntries)
{
// do something with fileName
String tree = "";
for (int i = 0; i < startLVL; i++)
tree += " ";
Label_showdata.Text += "<br />" + tree + Path.GetFileName(fileName);
}
// Going in subdirectories of this directory.
string[] subdirEntries = Directory.GetDirectories(sourceDir);
foreach (string subdir in subdirEntries)
if ((File.GetAttributes(subdir) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
GetImageFromDir(subdir, startLVL + 1);
}
}
这将在您的网页上(实际上在那个 Label_showdata 中)打印所有文件和它们所在的目录。基本上从这里开始,您需要将这些数据包装到一个表格中,并将其绑定到您觉得舒服的任何控件中......实际上并不难......但是编写所有代码需要更多时间(时间不幸的是我现在没有……)