settings.cs

来自「本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过」· CS 代码 · 共 49 行

CS
49
字号
using System;
using System.IO;


namespace SupermarketProject
{
	/// <summary>
	///Settings 的摘要说明。
	/// </summary>
	public class Settings
	{
		public string supermarketName, address, phone, fax, 
			mainDirectory, uiDirectory, appDirectory;
		public int maxUsers;
		public Settings()
		{
			this.appDirectory = Environment.CurrentDirectory; 
			this.mainDirectory = this.appDirectory;
			this.uiDirectory = this.appDirectory;

			try
			{
				StreamReader textStream = new StreamReader(mainDirectory + @"\Settings.txt",System.Text .Encoding .Default );
			
				supermarketName = textStream.ReadLine();
				textStream.ReadLine();
				string test;
				do
				{
					test = textStream.ReadLine();
					if (test.CompareTo("电话") < 0)
						address += test+"\n";
					else
						phone = test;
				}while (test.CompareTo("电话")< 0);		
				fax = textStream.ReadLine();				
				maxUsers = int.Parse(textStream.ReadLine() .Substring(6));
				DataConnection.database = textStream.ReadLine() .Substring(4);
					
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message );
			}
		}//构造函数结尾
	}//类结尾
}//名称空间结尾

⌨️ 快捷键说明

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