- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Text;
- using System.Collections;
- /*
- ' 迅龙中文分类搜索引擎 v0.6
- '
- ' LGPL 许可发行
- '
- ' 宁夏大学 张冬 康彩 zd4004@163.com
- '
- ' 官网 http://blog.163.com/zd4004/
- */
- namespace XunLong.CongifData
- {
- /// <summary>
- /// web服务器_系统配置文件
- /// </summary>
- public static class Config_web
- {
- /// <summary>
- /// WebSiteD:\XunLong\XunLong.BIN\XLDICT\WebSite
- /// </summary>
- public static string WebSite = "";
- /// <summary>
- /// web服务器绑定端口800
- /// </summary>
- public static int WebPort = 0;
- /// <summary>
- /// web服务器绑定地址127.0.0.1
- /// </summary>
- public static string WebIP = "";
- /// <summary>
- /// 主类别和地址对应表 key = 主类别 val = 对应索引地址
- /// </summary>
- public static Hashtable mainType = new Hashtable();
- /// <summary>
- /// 初始化配置数据 名称为 TuDou.kc 放在本地路径下
- /// </summary>
- /// <param name="path"></param>
- public static void InitConfigData(string sPath)
- {
- Hashtable c = new Hashtable();
- mainType.Clear();
- StreamReader reader = null;
- try
- {
- reader = new StreamReader(sPath, System.Text.Encoding.GetEncoding("gb2312"));
- for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
- {
- if ((line.Length > 0) & (line.IndexOf('=') > 0))
- {
- string[] x = line.Split('=');
- if (x.Length == 2)
- {
- //Index = 文学|c:win
- if (x[0].Trim() == "Index")
- {
- string[] x_1_s = x[1].Trim().Split('|');
- mainType.Add(x_1_s[0], x_1_s[1]);
- }
- else
- {
- c.Add(x[0].Trim(), x[1].Trim());
- }
- }
- }
- }
- reader.Close();
- }
- catch (IOException e)
- {
- Console.WriteLine(e.Message);
- }
- finally
- {
- if (reader != null)
- reader.Close();
- }
- foreach (DictionaryEntry a in c)
- {
- string a_one = a.Key.ToString().ToLower().Trim();
- a_one =a_one.Replace("t","");
- a_one =a_one.Replace(" ","");
- a_one =a_one.Replace("r","");
- a_one =a_one.Replace("n","");
- // WebSite
- // D:XunLongXunLong.BINXLDICTWebSite
- if (a_one == "website")
- {
- WebSite = a.Value.ToString().Trim();
- }
- ///web服务器绑定地址
- if (a_one == "webip")
- {
- WebIP = a.Value.ToString().Trim();
- }
- /// web服务器绑定端口
- if (a_one == "webport")
- {
- WebPort = Int32.Parse(a.Value.ToString().Trim());
- }
- }
- }
- }
- }