救命啊 请高手帮我看看为什么我在相对路径上无法读到文件
ShowOnPage = " ";
string strDir = HttpContext.Current.Server.MapPath( "DataBaseUse/BackUp ");
System.IO.DirectoryInfo rootDir = new System.IO.DirectoryInfo(strDir);
DirectoryInfo[] diArr = rootDir.GetDirectories();
ShowOnPage = @ " <table width= '100% ' align= 'center '> ";
//获取子文件夹
foreach (System.IO.DirectoryInfo folder1 in diArr)
{
ShowOnPage += " <tr align= 'center '> <td width=50% align= 'center '> " + folder1.Name + " <td> <td width=50% align= 'center '> <a href= 'BackUp.aspx?id= "+folder1.Name+ " '> 删除备份 </a> <td> </tr> ";
}
ShowOnPage += " </table> ";
this.Page.DataBind();
------解决方案--------------------你现在是什么问题,你的ShowOnPage没有输出,所以看不出效果,然后在字符串组合的时候最好别用string,而用System.Text.StringBuilder;
try:
ShowOnPage += " </table> ";
Response.Write(ShowOnPage.ToString());