M
Mr. B
I'm writing an app where I'm trying to look for and List all specific file
'types' found. So I point to a specific start top level Folder... and I want
to drill down through ALL sub folders to find file types (using File
Extenion).
All found DWG files are listed in "lbDwgList" Listbox.
I can get the top level and the 'immediate' level below the top level... but I
can't figure out how to keep going down X levels (ie: All sub-levels). Any
help appreciated!
Here's what I've go so far:
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Dim DWGFilPth As String ' DWG Files Path
Dim DWGfilname As String ' DWG Name
Dim DWGtestname As String ' DWG Test Name
(((#Region " Windows Form Designer generated code ")))
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' *********
' Form Load
' *********
' *********** Start Folder Paths ***********
DWGFilPth = "P:\Projects\"
' ******************************************
' Find Plot Styles in Multiple Folders and Lists them
' Get Folder Names Listing in DWGs Path
Dim rootDi As New DirectoryInfo(DWGFilPth)
' Look for DWG's in Root DWG File Path
Dim DWGdirsRt() As String = Directory.GetFiles(DWGFilPth)
For Each DWGfilname In DWGdirsRt
DWGtestname = System.IO.Path.GetFileName(DWGfilname)
' Test for DWG files
Dim FilTest As String = DWGtestname.Remove(0, (Len(DWGtestname) - 3))
If UCase(FilTest) = "DWG" Then
lbDwgList.Items.Add(DWGtestname)
End If
Next
' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
Dim DWGdirs() As String = Directory.GetFiles(DWGFilPth & di.Name)
For Each DWGfilname In DWGdirs
DWGtestname = System.IO.Path.GetFileName(DWGfilname)
' Test for DWG files
Dim FilTest As String = DWGtestname.Remove(0, (Len(DWGtestname) - 3))
If UCase(FilTest) = "DWG" Then
lbDwgList.Items.Add(DWGtestname)
End If
Next
Next
' *************
' End Form Load
' *************
End Sub
End Class
Regards,
Bruce
'types' found. So I point to a specific start top level Folder... and I want
to drill down through ALL sub folders to find file types (using File
Extenion).
All found DWG files are listed in "lbDwgList" Listbox.
I can get the top level and the 'immediate' level below the top level... but I
can't figure out how to keep going down X levels (ie: All sub-levels). Any
help appreciated!
Here's what I've go so far:
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Dim DWGFilPth As String ' DWG Files Path
Dim DWGfilname As String ' DWG Name
Dim DWGtestname As String ' DWG Test Name
(((#Region " Windows Form Designer generated code ")))
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' *********
' Form Load
' *********
' *********** Start Folder Paths ***********
DWGFilPth = "P:\Projects\"
' ******************************************
' Find Plot Styles in Multiple Folders and Lists them
' Get Folder Names Listing in DWGs Path
Dim rootDi As New DirectoryInfo(DWGFilPth)
' Look for DWG's in Root DWG File Path
Dim DWGdirsRt() As String = Directory.GetFiles(DWGFilPth)
For Each DWGfilname In DWGdirsRt
DWGtestname = System.IO.Path.GetFileName(DWGfilname)
' Test for DWG files
Dim FilTest As String = DWGtestname.Remove(0, (Len(DWGtestname) - 3))
If UCase(FilTest) = "DWG" Then
lbDwgList.Items.Add(DWGtestname)
End If
Next
' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
Dim DWGdirs() As String = Directory.GetFiles(DWGFilPth & di.Name)
For Each DWGfilname In DWGdirs
DWGtestname = System.IO.Path.GetFileName(DWGfilname)
' Test for DWG files
Dim FilTest As String = DWGtestname.Remove(0, (Len(DWGtestname) - 3))
If UCase(FilTest) = "DWG" Then
lbDwgList.Items.Add(DWGtestname)
End If
Next
Next
' *************
' End Form Load
' *************
End Sub
End Class
Regards,
Bruce