简体   繁体   English

如何获取没有扩展名/目录的启动文件的文件名?

[英]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.

相关问题 我如何识别启动我的应用程序的文件 - How do I identify the file that launched my application 如何获取我的项目的基本目录(.vbproj 或 .sln 文件所在的路径) - How do I get the Base Directory of my Project (The path where the .vbproj or .sln file are located) 如何使用文件名目录打开文件夹? - How do I open a folder using the filename directory? 如何使VS扩展程序显示在扩展程序管理器中? - How do I get my VS extension to show up in the extension manager? 如何在不知道用户名的情况下移动/下载文件做目录? - How do I move/download a file do a directory without knowing users name? 如何使用该VB表单启动的流程的VB表单中获取流程ID? - How Do I get the Process ID within a VB Form of a Process I Launched with that VB Form? 如何在VB中启动.bat文件而不将其与启动它的程序相关联? - How to launch a .bat file in VB without associating the file with the program that launched it? 如何将文本文件作为构建的一部分? - How do I get a text file to be a part of my build? 如何下载自定义目录中的文件? - How do I download a file in a custom directory? 如何在WinForm应用程序项目中获取目录的路径 - How do I get path of the Directory inside my WinForm app project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM