PC机和移动设备上绝对路径的获取(C#)

2010-08-28 10:55:12来源:西部e网作者:

最近写了两个WinForm的小应用程序,都是读取ini配置文件,不同的是一个在一般PC机上Windows运行,一个在Windows Mobile操作系统上运行,获取ini文件路径的方式是完全不同的,这里icech就记录一下!

获取PC上的绝对路径
string appPath = Application.StartupPath;//获取路径
INIFile ini = new INIFile(appPath + @"\config.ini");

获取移动设备开发中的绝对路径
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);//获取路径
INIFile ini = new INIFile(appPath + @"\config.ini");

文本为西部e网(yiiwa.net)原创,版权所有,转载请注名出处,谢谢!

关键词:C#

赞助商链接: