Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

how do i list folders and subfolders

Avatar of DDLY-Steve
DDLY-Steve asked on
Visual Basic.NET
3 Comments1 Solution305 ViewsLast Modified:
I have written code to show the full file path of each file, the size and its ntfs owner, my only problem is that i dont know how to feed in all subfolders and files for the drive.
thanx in advance,
Imports System.IO
Imports System.Security.AccessControl
Imports System.Security.Principal
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    Private Function Owners(ByVal file As String) As String
        Dim di As New DirectoryInfo(file)
        Dim ds As DirectorySecurity = di.GetAccessControl()
        Dim ow As NTAccount = CType(ds.GetOwner(GetType(NTAccount)), NTAccount)
        Owners = (ow.ToString)
    End Function
    Private Sub FileFolderList()
        Dim files = From file In My.Computer.FileSystem.GetFiles("e:\") _
                    Select file
        Dim fileinfo = From file In files _
                        Select Path = My.Computer.FileSystem.GetFileInfo(file).FullName, SizeKB = My.Computer.FileSystem.GetFileInfo(file).Length / 1024, Owner = Owners(file)
        DataGridView1.DataSource = fileinfo.ToList
        DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
    End Sub
End Class
Avatar of Mike Tomlinson
Mike TomlinsonFlag of United States of America imageHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers