获取程序的根目录
WINFROM:
StreamReader sr = new StreamReader(Application.StartupPath + "\\config.txt", Encoding.Default);//获取路径
string cityInfo = sr.ReadToEnd();//读取内容
sr.Close();//关闭流
解释:读取程序的根目录中 名称为config.txt文件的内容
WEBFROM:
StreamReader sr = new StreamReader(System.AppDomain.CurrentDomain.BaseDirectory + "\\config.txt", Encoding.Default);