Config_web.cs
上传用户:zhangkuixh
上传日期:2013-09-30
资源大小:5473k
文件大小:4k
源码类别:

搜索引擎

开发平台:

C#

  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Collections;
  6. /*
  7.       '       迅龙中文分类搜索引擎  v0.6
  8.       '
  9.       '        LGPL  许可发行
  10.       '
  11.       '       宁夏大学  张冬 康彩  zd4004@163.com
  12.       ' 
  13.       '        官网 http://blog.163.com/zd4004/
  14.  */
  15. namespace XunLong.CongifData
  16. {
  17.     /// <summary>
  18.     /// web服务器_系统配置文件
  19.     /// </summary>
  20.     public static class Config_web
  21.     {
  22.         /// <summary>
  23.         /// WebSiteD:\XunLong\XunLong.BIN\XLDICT\WebSite
  24.         /// </summary>
  25.         public static string WebSite = "";
  26.        
  27.         /// <summary>
  28.         /// web服务器绑定端口800
  29.         /// </summary>
  30.         public static int WebPort = 0;
  31.         
  32.         /// <summary>
  33.         /// web服务器绑定地址127.0.0.1
  34.         /// </summary>
  35.         public static string WebIP = "";
  36.         /// <summary>
  37.         /// 主类别和地址对应表  key = 主类别 val = 对应索引地址
  38.         /// </summary>
  39.         public static Hashtable mainType = new Hashtable();
  40.          /// <summary>
  41.         /// 初始化配置数据  名称为 TuDou.kc 放在本地路径下 
  42.         /// </summary>
  43.         /// <param name="path"></param>
  44.         public static void InitConfigData(string sPath)
  45.         {
  46.             Hashtable c = new Hashtable();
  47.             mainType.Clear();
  48.             StreamReader reader = null;
  49.             try
  50.             {
  51.                 reader = new StreamReader(sPath, System.Text.Encoding.GetEncoding("gb2312"));
  52.                 for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
  53.                 {
  54.                     if ((line.Length > 0) & (line.IndexOf('=') > 0))
  55.                     {
  56.                         string[] x = line.Split('=');
  57.                         if (x.Length == 2)
  58.                         {
  59.                             //Index = 文学|c:win
  60.                             if (x[0].Trim() == "Index")
  61.                             {
  62.                                 string[] x_1_s = x[1].Trim().Split('|');
  63.                                 mainType.Add(x_1_s[0], x_1_s[1]);
  64.                             }
  65.                             else
  66.                             {
  67.                                 c.Add(x[0].Trim(), x[1].Trim());
  68.                             }
  69.                         }
  70.                     }
  71.                 }
  72.                 reader.Close();
  73.             }
  74.             catch (IOException e)
  75.             {
  76.                 Console.WriteLine(e.Message);
  77.             }
  78.             finally
  79.             {
  80.                 if (reader != null)
  81.                     reader.Close();
  82.             }
  83.             foreach (DictionaryEntry a in c)
  84.             {
  85.                 string a_one = a.Key.ToString().ToLower().Trim();
  86.                 a_one =a_one.Replace("t","");
  87.                   a_one =a_one.Replace(" ","");
  88.                   a_one =a_one.Replace("r","");
  89.                   a_one =a_one.Replace("n","");
  90.                 // WebSite
  91.                 // D:XunLongXunLong.BINXLDICTWebSite
  92.                 if (a_one == "website")
  93.                 {
  94.                     WebSite = a.Value.ToString().Trim();
  95.                 }
  96.                 ///web服务器绑定地址
  97.                 if (a_one == "webip")
  98.                 {
  99.                     WebIP = a.Value.ToString().Trim();
  100.                 }
  101.                 /// web服务器绑定端口
  102.                 if (a_one == "webport")
  103.                 {
  104.                     WebPort = Int32.Parse(a.Value.ToString().Trim());
  105.                 }
  106.             }
  107.         }
  108.     }
  109. }