Beispiel #1
0
        /// <summary>
        /// 输出页面
        /// </summary>
        /// <param name="lstDirectory"></param>
        /// <param name="lstFiles"></param>
        private void PutPage(PageModelInfo pageInfo, ResponseInfo response)
        {
            string content = _model;

            content = content.Replace("<#=Root#>", pageInfo.CurLoaction);
            content = content.Replace("<#=DirectoryItems#>", GenDirectoryHtml(pageInfo.Directorys));
            content = content.Replace("<#=FileItems#>", GenFileHtml(pageInfo.Files));
            response.Write(content);
        }
Beispiel #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);
        }