C#中获取当前运行目录路径方法


第一种方法:
 string AppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
 if (AppPath.EndsWith("\\") || AppPath.EndsWith("/"))
     AppPath= AppPath.Substring(0, AppPath.Length - 1);

第二种方法:
string AppPath = Environment.CurrentDirectory; // 结尾不带"/"


第三种方法:
string AppPath = Directory.GetCurrentDirectory();//获取应用程序的当前工作目录
Directory.SetCurrentDirectory(localFolder); //将应用程序的当前工作目录设置为指定目录
posted @ 2008-03-24 16:03 FreeBird 阅读(951) 评论(0)  编辑 收藏