Combobox只是文件名(没有扩展名或路径)VB.Net [英] Combobox just file name (without extention or path) VB.Net
本文介绍了Combobox只是文件名(没有扩展名或路径)VB.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了以下代码,它是好的,但它返回整个路径以及名称
I got the following code which is nice and all however it returns the entire path as well as name
For Each s As String In System.IO.Directory.GetFiles("C:\VTS\TREADSTONE LT\ATC\BASIS\")
combobox1.Items.Add(s)
Next
我后面是文件名,最好没有扩展名...
What I'm after is the file name only and preferably without its extention...
UPDATE
For Each s As String In GetFileNameWithoutExtension("C:\VTS\TREADSTONE LT\ATC\BASIS\")
combobox1.Items.Add(s)
Next
推荐答案
您需要在内使用路径类:
Dim dir = "C:\VTS\TREADSTONE LT\ATC\BASIS\"
For Each file As String In System.IO.Directory.GetFiles(dir)
combobox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
Next
这篇关于Combobox只是文件名(没有扩展名或路径)VB.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文