⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.cs

📁 用C#编写的一个款搜索engine的源代码!摘自<Visual c#2005 程序设计>
💻 CS
字号:
using System;
using System.Text;
using System.IO;

namespace SECompare.Config
{
	public class Config
	{
		private String m_SamplingedQueryRoot;
		private String m_SampleRoot;
		private String m_DataRoot;

		public Config()
		{
			this.Load();
		}

		public String SamplingedQueryRoot
		{
			get
			{
				return this.m_SamplingedQueryRoot;
			}
			set
			{
				this.m_SamplingedQueryRoot = value;
			}
		}


		public String SampleRoot
		{
			get
			{
				return this.m_SampleRoot;
			}
			set
			{
				this.m_SampleRoot = value;
			}
		}

		public String DataRoot
		{
			get
			{
				return this.m_DataRoot;
			}
			set
			{
				this.m_DataRoot = value;
			}
		}

		public void Load()
		{
			if(!File.Exists("config.ini"))
            {
                new FileNotFoundException("Can not find config.ini");
			}

			StreamReader reader = new StreamReader("config.ini");
			String line;
			line = reader.ReadLine();
			while(line!=null)
			{
				//Skip empty line and comment line
				if(!line.Equals("")&&!line.StartsWith("#"))
				{
					//split key string and value string
					String[] splits = line.Split(new char[]{'='});
					String type = splits[0];
					if(type.Equals("SamplingedQueryRoot"))
						this.m_SamplingedQueryRoot = splits[1];
					if(type.Equals("SampleRoot"))
						this.m_SampleRoot = splits[1];
					if(type.Equals("DataRoot"))
						this.m_DataRoot = splits[1];
				}
				line = reader.ReadLine();
			}
			reader.Close();
		}

		public void Save()
		{
			FileInfo file = new FileInfo("config.ini");	
			StreamWriter w = new StreamWriter(file.FullName,false);
			w.WriteLine("SamplingedQueryRoot="+this.m_SamplingedQueryRoot);
			w.WriteLine("SampleRoot="+this.m_SampleRoot);
			w.WriteLine("DataRoot="+this.m_DataRoot);
			w.Close();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -