C#在WinXP和WinCE裏獲取應用程序當前路徑的通用函數

PS:可以寫成靜態方法,編譯到動態庫裏,到處都可以用了。
using System.IO;
using System.Reflection;
public class Configs
 {
  private string m_CurrentPath;
 
  private string Platform
  {
   get
   {
    return Environment.OSVersion.Platform.ToString();
   }
  }
 
  public string CurrentPath
  {
   get
   {
   
    if(Platform.Equals("WinCE"))
    {
     m_CurrentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
    }
    else if(Platform.Equals("Win32NT"))
    {
     m_CurrentPath = Directory.GetCurrentDirectory();
    }

    return m_CurrentPath;
   }
  }
 
  public Configs()
  {
  
  }
 }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章