首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请高手帮小弟我看看为什么小弟我在相对路径上无法读到文件

2011-12-27 
救命啊 请高手帮我看看为什么我在相对路径上无法读到文件ShowOnPage stringstrDirHttpContext.Curren

救命啊 请高手帮我看看为什么我在相对路径上无法读到文件
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());

热点排行