一般我們在做開發的時候要用到目前執行檔的位置通常會這樣用
Application.StartupPath
但是到了裝置上面沒有這個東西可以用,怎麼辦呢?我們可以利用下面的方式來取得

  1. Public Function GetAppPath() As String  
  2.         Return System.IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase.ToString)  
  3. End Function  


 

如果你是用C#的話請用下面這個


 

  1. MessageBox.Show(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)); 

bauann@dotblog