如何在未列出目录或扩展名的情况下找到已启动的vb.net项目的当前名称?
我已经搜索了其他解决方案,但是所有这些解决方案都有扩展名,和/或开头的目录位置,我只想要普通文件名,没有扩展名,没有目录。< / p>
示例:
Dim Filename as string = (code that finds the file name)
MsgBox(Filename)
对于此示例,将输出Test
,该程序名为Test.exe
答案 0 :(得分:3)
如果这是一个WinForms应用程序:
Dim fileName = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
答案 1 :(得分:0)
你试过看过这个吗?
Dim PathofYourFile As String = "c:\MyDirectory\MYFile.txt"
Dim FileName As String = IO.Path.GetExtension(PathofYourFile)
MsgBox(FileName)
答案 2 :(得分:-1)
我尝试过:
Public Class FOL
Dim MyFileName = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
Private Sub FOL_Load(sender As Object, e As EventArgs) Handles Me.Load
If MyFileName.Equals("fol") Then
Updater.Show()
End If
End Sub
End Class
此示例在加载主表单之前打开定义的表单“ Updater”。