2 cc222014 cc222014 于 2017.09.11 20:47 提问

VB.net 获取指定文件夹下文件名的问题
System.IO.Directory.GetFiles中的路径如果明确指定就可以,如果按照下面这种方法就不行,求大神指点

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    Dim nowdatabasePath As String
    nowdatabasePath = Application.StartupPath & "\DataBase\data"
    nowdatabasePath = nowdatabasePath & ComboBox1.SelectedItem & ComboBox2.SelectedItem
    'ListBox1.Items.Clear()
    Try

        Dim files = System.IO.Directory.GetFiles(nowdatabasePath, "*.xls") '"E:\Excel"

        For Each f As String In files
            MsgBox(f)
            ' ListBox1.Items.Add(f)
        Next f

    Catch ex As Exception
        MsgBox("读取文件出错")

    End Try

End Sub

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.12 09:14

上次的问题还没有采纳呢。先采纳了再回答新的问题。

Csdn user default icon
上传中...
上传图片
插入图片