如何使用vb.net代码显示所有文件和文件夹 [英] How to display all the files and folders using vb.net code

查看:126
本文介绍了如何使用vb.net代码显示所有文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以帮忙一些代码,如何使用vb.net显示所有文件夹和文件,如果我也可以选择该文件夹,还有另一件事会有所帮助吗?
我尝试了这段代码,但是我没有得到输出,只是它正在执行

Hi,

Can anybody help with some code, how to display all the folders and files using vb.net, and one more thing will be advantage that if i can select the folder too?
I tried this code but iam not getting output, simply it is executing

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' make a reference to a directory
        Dim di As New IO.DirectoryInfo("c:\")
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo

        'list the names of all files in the specified directory
        For Each dra In diar1
            ListBox1.Items.Add(dra)
        Next
    End Sub



请提供一些代码.



Please help with some code.

推荐答案

Anil Sarda写道:
Anil Sarda wrote:

ListBox1.Items .add(dra)

ListBox1.Items.Add(dra)


尝试使用ListBox1.Items.Add(dra.FullName).


Try ListBox1.Items.Add(dra.FullName) instead.


这篇关于如何使用vb.net代码显示所有文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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