Get a list of all files inside of a directory in vb.net

扶醉桌前 提交于 2019-11-26 14:19:20

问题


How can you obtain a list of files (as a stringcollection or some other storage method) which contains the full path on the user's computer to the files?

Is there a method for doing so?


回答1:


It looks like you want to use Directory.GetFiles() in the System.IO namespace.

Docs here.




回答2:


    Dim txtFiles = Directory.GetFiles("C:\Input", "*.CSV", SearchOption.TopDirectoryOnly).
        [Select](Function(nm) Path.GetFileName(nm))

    Dim arrayList As New System.Collections.ArrayList()
    For Each filenm As String In txtFiles
        arrayList.Add(New clsImportFiles(filenm))
    Next



回答3:


Add a Listbox to Windows Form and Add following code on Form Load or other events :-

ListBox1.Items.AddRange(Directory.GetFiles("Your Directory PAth Here"))

Hope IT Helps ; From Nirav



来源:https://stackoverflow.com/questions/1457525/get-a-list-of-all-files-inside-of-a-directory-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!