在标签中显示文本文件名称? [英] Display Text file Name In Label?

查看:74
本文介绍了在标签中显示文本文件名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

起初我想知道是否可以仅将我的文本文件中的第一行文本显示在标签上,但是我认为显示文件本身的名称可能会更容易. 123.txt没有文件扩展名,因此它只读取123

是否有捷径可寻?
:p ...

I was at first wonding if it was possible to display the first line of text only in my text file to a label but thought it may be easier to display the name of the file itself eg. 123.txt without the file extention so it just reads 123

is there an easy way to do this?
:p...

推荐答案

您可以使用 ^ ],例如

You may use the GetFilenameWithoutExtension of the Path class[^] , for instance

Imports System.IO
  Module Module1
  Sub Main()
    Dim mypath As String = "c:\temp\123.txt"
    Dim myfilename = Path.GetFileNameWithoutExtension(mypath)
    Console.WriteLine(myfilename)
  End Sub


这篇关于在标签中显示文本文件名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆