37
A
回答
28
Application.Current結果 http://msdn.microsoft.com/en-us/library/system.appdomain_members.aspx
而且這應該給你組裝的
AppDomain.CurrentDomain.BaseDirectory
我似乎記得位置有多種獲取應用程序位置的方法。但是這一次,在過去ATLEAST工作對我來說(它已經有一段時間,因爲我已經做的WinForms編程:/)
55
在VB.NET
Dim directory as String = My.Application.Info.DirectoryPath
在C#
string directory = AppDomain.CurrentDomain.BaseDirectory;
12
0
string apppath =
(new System.IO.FileInfo
(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).DirectoryName;
9
System.Windows.Forms.Application.StartupPath
將解決你的問題,我覺得
1
檢查了這一點
'as in import statement you have to mention the Imports System.IO & import System.Management
Imports System.IO
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = Path.GetFullPath(Application.ExecutablePath)
Process.Start(TextBox1.Text)
End Sub
End Class
2
這兩個例子都在VB.NET中。
調試路徑:
TextBox1.Text = My.Application.Info.DirectoryPath
EXE路徑:
TextBox2.Text = IO.Path.GetFullPath(Application.ExecutablePath)
0
私人小組Main_Shown(發送者爲對象,例如作爲EventArgs的)把手Me.Shown
Dim args() As String = Environment.GetCommandLineArgs()
If args.Length > 0 Then
TextBox1.Text = Path.GetFullPath(Application.ExecutablePath)
Process.Start(TextBox1.Text)
End If
End Sub
相關問題
- 1. 獲取應用程序文件路徑在Windows窗體應用程序
- 2. 獲取拖入Windows窗體窗體的文件的路徑
- 3. 如何在iOS中獲取目錄的路徑應用程序
- 4. Zend Framework 2:獲取應用程序根目錄的路徑
- 5. 如何獲取應用程序目錄的路徑?
- 6. 如何獲取完整的目錄應用程序路徑?
- 7. 獲取應用程序目錄的完整路徑
- 8. 獲取相對於執行燒瓶的路徑應用程序
- 9. Windows窗體應用程序中的相對路徑
- 10. 在Windows窗體應用程序中獲取IIS文件夾物理路徑
- 11. 獲取用於執行Web應用程序的類路徑條目
- 12. 檢測C#窗體窗體應用程序的啓動路徑
- 13. 記錄C#程序的執行路徑?
- 14. 獲取應用程序的路徑
- 15. 發佈Windows窗體應用程序 - 路徑太長
- 16. 如何獲取我的WinForm應用程序項目中的目錄路徑
- 17. 獲取「應用程序數據」目錄路徑的最佳途徑?
- 18. 應用程序目錄路徑
- 19. RegistryKey在Windows窗體應用程序上執行的操作
- 20. 獲取主可執行文件.jar文件的目錄路徑
- 21. WPF應用程序執行路徑
- 22. C++獲取程序文件目錄,追加額外路徑並執行
- 23. 使用JFileChooser獲取目錄的路徑
- 24. Dropwizard路徑:獲取應用程序中的所有路徑
- 25. 在Netbeans中逐步執行應用程序的執行路徑
- 26. Windows窗體應用程序
- 27. C - 獲取目錄路徑
- 28. 獲取與應用程序域路徑相同的目錄中的文件夾
- 29. C# - 獲取Windows窗體應用程序中SelectedItem的值
- 30. 獲取正在運行的進程的目錄路徑ID
C#位置也可以在VB或其他語言中使用es不支持「我的」名字。 – 2008-11-17 14:53:08
@Tomas Pajonk,我可以建議將c#「FileName」變量更改爲「directory」嗎? – grenade 2010-04-21 09:32:49
@榴彈完成。謝謝。 – 2010-04-21 09:41:48