[英]How do I get the filename of my launched file without extension / directory?
How do I find the current name of my launched vb.net project without listing the directory or extension? 如何找到启动的vb.net项目的当前名称而不列出目录或扩展名?
I've searched for other solutions, but all of them either has the extension at the end, and/or the directory location at the start, I just want the plain file name, no extension, no directory. 我已经搜索了其他解决方案,但是所有这些解决方案要么要么都以扩展名结尾,和/或以目录位置开头,但我只想使用纯文件名,没有扩展名,没有目录。
Example: 例:
Dim Filename as string = (code that finds the file name)
MsgBox(Filename)
Which would output Test
as for this example the program was named Test.exe
对于该示例,它将输出
Test
,该程序名为Test.exe
如果这是WinForms应用程序:
Dim fileName = IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)
Have you tried to look at this one? 你试过看看这个吗?
Dim PathofYourFile As String = "c:\MyDirectory\MYFile.txt"
Dim FileName As String = IO.Path.GetExtension(PathofYourFile)
MsgBox(FileName)
I tried this: 我尝试了这个:
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
This example opens defined form "Updater" before loads main form. 本示例在加载主表单之前打开定义的表单“ Updater”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.