点击回首页
我的浏览记录 | | 帮助?
当前位置:

源码截图

源码目录树

当前路径:InsApp/WebSearch/ReadWebSiteXml.cs     using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using System.Net;
using System.Web;
using InsApp.word;

namespace InsApp.WebSearch
{
    //该源码下载自www.51aspx.com(51aspx.com)

    public class ReadWebSiteXml
    {
        ///读取网站配置文档

        InsApp.word.FileClass CheckNullstr = new FileClass();
        string FilePath;

        public ReadWebSiteXml()
        {
            FilePath = System.Configuration.ConfigurationManager.AppSettings["Web_Info"];
            FilePath = System.Web.HttpContext.Current.Server.MapPath(FilePath);
        }

    #region  string[] ReadWebSiteTitle()读取xml文档
        /// <summary>
        /// 读取网站配置文件,得到相关内容
        /// </summary>
        /// <param name="FilePath"></param>
        public string[] ReadWebSiteTitle()
        {
            //Webname=title,WebMeta=webcontent,WebCopyright=Copyright
            //WebKey    关键字共有4个
            string[] WebSystem=new string[4];

            try
            {
                if (!File.Exists(FilePath))
                {
                    throw new Exception("文件不存在");
                }
                else
                {
                    ///读取配置文件 WebInfo/Info/Webname
                    using (XmlReader reader = XmlReader.Create(FilePath))
                    {
                        reader.Read();
                        reader.ReadStartElement("WebInfo");
                        reader.ReadStartElement("Info");
                        reader.ReadStartElement("Webname");
                        WebSystem[0] = reader.ReadString();
                        reader.ReadEndElement();
                        reader.ReadStartElement("WebMeta");         //网站meta
                        WebSystem[1] = reader.ReadString();
                        reader.ReadEndElement();
                        reader.ReadStartElement("WebCopyRight");
                        WebSystem[2] = reader.ReadString();         //WebCopyRight  页面底部文件
                        reader.ReadEndElement();
                        reader.ReadStartElement("WebKey");
                        WebSystem[3] = reader.ReadString();         //WebKey  meat关键字
                        reader.ReadEndElement();
                        reader.Close();
                        return WebSystem;
                    }
                }
            }
            catch(Exception ex) 
            {

                throw new Exception(ex.Message.ToString());
            }

        }
        #endregion

    #region  string[] ReadWebSiteTitle(string FilePath,int ArrayLength)读取xml文档
/// <summary>
/// 读取网站配置文件,得到相关内容
/// </summary>
/// <param name="FilePath">网站配置文件</param>
/// <param name="ArrayLength">数组长度</param>
/// <param name="Obj_Source">对象长度</param>
/// <returns></returns>
        public string ReadWebSiteTitle(string FilePath)
        {
            string WebSystem = string.Empty;
            try
            {
                if (!File.Exists(FilePath))
                {
                    throw new Exception("文件不存在");
                }
                else
                {
                    XmlTextReader Reader = new XmlTextReader(FilePath);
                    Reader.WhitespaceHandling = WhitespaceHandling.None;

                    while (Reader.Read())
                    {
                        switch (Reader.NodeType)
                        {
                            case XmlNodeType.Text:
                                if (CheckNullstr.CheckNullstr(Reader.Value) == true)
                                {
                                    WebSystem+= "<option>"+Reader.Value.Trim()+"</option>";
                                }
                            break;
                        }
                    }
                    return WebSystem;
                }
            }
            catch(Exception ex)
            {

                throw new Exception(ex.Message.ToString());
            }

        }
        #endregion

    #region  读取压制视频的程序路径
        /// <summary>
        /// 读取网站配置文件,得到相关内容
        /// </summary>
        /// <param name="FilePath"></param>
        public string[] Read_Applcation_Path()
        {
            //WebKey    关键字共有4个
            string[] WebSystem = new string[2];
            string FilePath1=System.Web.HttpContext.Current.Server.MapPath("~//App_Config//Application.xml");
            try
            {
            if (CheckNullstr.Check_File(FilePath1, "file", false) == false)
            {
                throw new Exception("配置文件不存在,请重新配置站点。");
            }
            else
            {
                ///读取配置文件 App_Path/Application/ffmpeg    mencoder
                using (XmlReader reader = XmlReader.Create(FilePath1))
                {
                    reader.Read();
                    reader.ReadStartElement("App_Path");
                    reader.ReadStartElement("Application");
                    reader.ReadStartElement("ffmpeg");              //外部程序路径1
                    WebSystem[0] = reader.ReadString();
                    reader.ReadEndElement();
                    reader.ReadStartElement("mencoder");            //外部程序路径2
                    WebSystem[1] = reader.ReadString();
                    reader.ReadEndElement();
                    reader.Close();
                    return WebSystem;
                }
            }
            }
            catch (Exception ex)
            {

                throw new Exception(ex.Message.ToString());
            }

        }
        #endregion

    }
}
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途) 企业QQ:4000410510
地址:北京市海淀区中关村鼎好大厦A座二层 邮编:100080
Room A-801,Dinghao Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
在线客服
分享该页面
关闭侧边栏