WinCE取得應用程式路徑(轉載)

WinCE取得應用程式路徑(轉載)

SNAGHTML1ddb69b

   1:      public class Configs
   2:      {
   3:          private string m_CurrentPath;
   4:          //取得作業平台
   5:          private string Platform
   6:          {
   7:              get
   8:              {
   9:                  return Environment.OSVersion.Platform.ToString();
  10:              }
  11:          }
  12:   
  13:          public string CurrentPath
  14:          {
  15:              get
  16:              {
  17:                  if (Platform.Equals("WinCE"))
  18:                  {
  19:                      m_CurrentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
  20:                  }
  21:                  else if (Platform.Equals("Win32NT"))
  22:                  {
  23:                      m_CurrentPath = Directory.GetCurrentDirectory();
  24:                  }
  25:   
  26:                  return m_CurrentPath;
  27:              }
  28:          }
  29:   
  30:          public Configs()
  31:          {
  32:   
  33:          }
  34:      }
   1:  //實作
   2:          public Form1()
   3:          {
   4:              InitializeComponent();
   5:   
   6:              Configs config = new Configs();
   7:              MessageBox.Show(config.CurrentPath);
   8:          }