如何去掉文件后缀名
要求去掉,后缀名。
如果谁还能过滤掉其他格式只留TXT格式的文件,再去掉后缀就perfect了
[解决办法]
System.IO.Path.GetFileNameWithoutExtension()
[解决办法]
筛选扩展名,之前的那个帖子回过的。
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim di As New DirectoryInfo("D:\NewNetDisk\我的微盘")
ComboBox1.DataSource = di.GetDirectories()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim fi = CType(ComboBox1.SelectedValue, DirectoryInfo).GetFiles("*.txt")
Dim ds As New List(Of String)
For Each o In fi
ds.Add(Path.GetFileNameWithoutExtension(o.Name))
Next
ComboBox2.DataSource = ds
End Sub
End Class