昨天生成网站文件夹和文件的代码
protected void Button3_Click(object sender, EventArgs e)
{
loadNodes(Server.MapPath( "~/ "));
Response.Write(ifile);
}
void loadNodes(string path)
{
DirectoryInfo mainDir = new DirectoryInfo(path);
try
{
Response.Write( " <B> " + mainDir.Name + " </b> <br> ");
//遍历文件目录
foreach (FileInfo f in mainDir.GetFiles())
{
//增加文件
Response.Write(GetVirPath(f.FullName) + " <br> ");
//fileview
ifile++;
}
foreach (DirectoryInfo d in mainDir.GetDirectories())
{
//递归调用
loadNodes(d.FullName);
// loadNodes( d.FullName);
}
}
catch (Exception er)
{
Response.Write(er.ToString());
}
}
string GetVirPath(string FullName)
{