最近寫了兩個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");