Пример #1
0
        /// <summary>
        /// 生成目录的html
        /// </summary>
        /// <returns></returns>
        private string GenFileHtml(IList <DirInfo> lstFile)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < lstFile.Count; i++)
            {
                DirInfo info = lstFile[i];
                if (i % 2 == 1)
                {
                    sb.AppendLine("            <tr class=\"linePer\"" + GetMouseRoll() + ">");
                }
                else
                {
                    sb.AppendLine("            <tr class=\"line\"" + GetMouseRoll() + ">");
                }

                sb.AppendLine("            <td class=\"dic\">");
                sb.AppendLine("            &nbsp;");
                sb.AppendLine("            </td>");
                sb.AppendLine("                <td style=\" width:500px\" >");
                sb.AppendLine("                    " + System.Web.HttpUtility.HtmlEncode(info.Text));
                sb.AppendLine("                </td>");
                sb.AppendLine("                <td style=\" width:500px\" >");
                sb.AppendLine("                    " + System.Web.HttpUtility.HtmlEncode(info.LenString));
                sb.AppendLine("                </td>");
                sb.AppendLine("                <td >");
                sb.AppendLine("                    <a href=\"" + System.Web.HttpUtility.UrlEncode(info.Url) + "\" target=\"_blank\">下载</a>");
                sb.AppendLine("                </td>");
                sb.AppendLine("            </tr>");
            }
            return(sb.ToString());
        }
Пример #2
0
        /// <summary>
        /// 输出网页
        /// </summary>
        /// <param name="curDir"></param>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        private bool PutPageTo(string curDir, RequestInfo request, ResponseInfo response, string url)
        {
            PageModelInfo pageInfo = new PageModelInfo();

            pageInfo.CurLoaction = curDir;
            if (string.IsNullOrEmpty(curDir))
            {
                foreach (ShareInfo dinfo in _config.ShareInfos)
                {
                    DirInfo info = new DirInfo();
                    info.Text = dinfo.Name;
                    info.Url  = dinfo.Name;
                    pageInfo.Directorys.Add(info);
                }
            }
            else
            {
                if (Directory.Exists(curDir))
                {
                    string[] strdirs = Directory.GetDirectories(curDir);

                    DirectoryInfo dinfo = new DirectoryInfo(curDir);
                    DirInfo       info  = new DirInfo();
                    info.Text = "..";
                    info.Url  = "..";
                    pageInfo.Directorys.Add(info);
                    foreach (string strDir in strdirs)
                    {
                        dinfo     = new DirectoryInfo(strDir);
                        info      = new DirInfo();
                        info.Text = dinfo.Name;
                        info.Url  = dinfo.Name + "/";
                        pageInfo.Directorys.Add(info);
                    }
                    strdirs = Directory.GetFiles(curDir);
                    foreach (string strDir in strdirs)
                    {
                        FileInfo finf = new FileInfo(strDir);
                        info        = new DirInfo();
                        info.Text   = finf.Name;
                        info.Url    = finf.Name;
                        info.Length = finf.Length;
                        pageInfo.Files.Add(info);
                    }
                }
            }
            PutPage(pageInfo, response);
            return(true);
        }