473,487 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HLP: Finding file Types

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
Jul 21 '05 #1
8 2023
Hi Mr B,

You need to do it using a recursive function call. Add the following
function to your form...

\\\
Private Sub GetDWGFiles(ByVal DWGFilPth As String)
' 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)
Dim DWGfilname As String
Dim DWGtestname As String
For Each DWGfilname In DWGdirsRt
DWGtestname = System.IO.Path.GetFileName(DWGfilname)
' Look for DWG's in Root DWG File Path
If DWGtestname.Length >= 3 Then
Dim FilTest As String = DWGtestname.Remove(0,
(Len(DWGtestname) - 3))
' Test for DWG files
If UCase(FilTest) = "DWG" Then
lbDwgList.Items.Add(DWGtestname)
End If
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
AddFilesToList(di.FullName)
Next
End Sub
///

....then call the function in your Form_Load event...

\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' *********
' Form Load
' *********

GetDWGFiles("P:\Projects")

' *************
' End Form Load
' *************
End Sub
///

HTH,
Gary

"Mr. B" <Us**@NoWhere.com> wrote in message
news:md********************************@4ax.com...
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

Jul 21 '05 #2
With Deft Fingers, "Gary Milton" <an*******@discussions.microsoft.com> wrote:
You need to do it using a recursive function call. Add the following
function to your form... ' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
AddFilesToList(di.FullName)
Next
End Sub HTH,
Gary


Hmmmmm....

Looks like I need to work on this... Your example only displays the folders
under the Root folder :(

Oh well.. thanks for the reply... I might be able to work something out.

Regards,

Bruce
Jul 21 '05 #3
Hi Mr B,

You need to do it using a recursive function call. Add the following
function to your form...

\\\
Private Sub GetDWGFiles(ByVal DWGFilPth As String)
' 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)
Dim DWGfilname As String
Dim DWGtestname As String
For Each DWGfilname In DWGdirsRt
DWGtestname = System.IO.Path.GetFileName(DWGfilname)
' Look for DWG's in Root DWG File Path
If DWGtestname.Length >= 3 Then
Dim FilTest As String = DWGtestname.Remove(0,
(Len(DWGtestname) - 3))
' Test for DWG files
If UCase(FilTest) = "DWG" Then
lbDwgList.Items.Add(DWGtestname)
End If
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
AddFilesToList(di.FullName)
Next
End Sub
///

....then call the function in your Form_Load event...

\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' *********
' Form Load
' *********

GetDWGFiles("P:\Projects")

' *************
' End Form Load
' *************
End Sub
///

HTH,
Gary

"Mr. B" <Us**@NoWhere.com> wrote in message
news:md********************************@4ax.com...
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

Jul 21 '05 #4
With Deft Fingers, "Gary Milton" <an*******@discussions.microsoft.com> wrote:
You need to do it using a recursive function call. Add the following
function to your form... ' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
AddFilesToList(di.FullName)
Next
End Sub HTH,
Gary


Hmmmmm....

Looks like I need to work on this... Your example only displays the folders
under the Root folder :(

Oh well.. thanks for the reply... I might be able to work something out.

Regards,

Bruce
Jul 21 '05 #5
That was a typo - the recursion call should be...

\\\
' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
GetDWGFiles(di.FullName)
Next
///

Gary

"Mr. B" <Us**@NoWhere.com> wrote in message
news:vi********************************@4ax.com...
With Deft Fingers, "Gary Milton" <an*******@discussions.microsoft.com> wrote:
You need to do it using a recursive function call. Add the following
function to your form...
' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
AddFilesToList(di.FullName)
Next
End Sub

HTH,
Gary


Hmmmmm....

Looks like I need to work on this... Your example only displays the

folders under the Root folder :(

Oh well.. thanks for the reply... I might be able to work something out.

Regards,

Bruce

Jul 21 '05 #6
That was a typo - the recursion call should be...

\\\
' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
GetDWGFiles(di.FullName)
Next
///

Gary

"Mr. B" <Us**@NoWhere.com> wrote in message
news:vi********************************@4ax.com...
With Deft Fingers, "Gary Milton" <an*******@discussions.microsoft.com> wrote:
You need to do it using a recursive function call. Add the following
function to your form...
' Look for DWG's in Sub-Folders of DWG File Root Folder
Dim di As DirectoryInfo
For Each di In rootDi.GetDirectories
AddFilesToList(di.FullName)
Next
End Sub

HTH,
Gary


Hmmmmm....

Looks like I need to work on this... Your example only displays the

folders under the Root folder :(

Oh well.. thanks for the reply... I might be able to work something out.

Regards,

Bruce

Jul 21 '05 #7
With Deft Fingers, "Gary Milton" <an*******@discussions.microsoft.com> wrote:
That was a typo - the recursion call should be...


Aha! Excellent. Thanks Muchly.... nice to know how it's done!

Great stuff!

Regards,

Bruce
Jul 21 '05 #8
With Deft Fingers, "Gary Milton" <an*******@discussions.microsoft.com> wrote:
That was a typo - the recursion call should be...


Aha! Excellent. Thanks Muchly.... nice to know how it's done!

Great stuff!

Regards,

Bruce
Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1073
by: Thiago Guedes | last post by:
Hi, how can I open a .hlp file by a link in a asp.net page? *** <asp:hyperlink id="HyperLink1" runat="server" NavigateUrl="help/help.HLP">Help</asp:hyperlink> **** When the link open I dont...
0
251
by: Mr. B | last post by:
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...
0
1596
by: MLH | last post by:
I have the following code partially built from stuff I cut 'n pasted from A97 help... 120 Dim Msg, Style, Title, Help, Ctxt, Response, MyString 140 Msg = "You started to enter...
2
1413
by: I D via .NET 247 | last post by:
Hello, I am CSharp developer working on a bigger proeject. WHat is the best way to integrate help in a CSharp application. (I mean F1 sensitive help) I already created with Help&Manual a...
1
6004
by: xzzy | last post by:
How is a .HLP help file displayed from a C# winforms application? Thank you, John Bickmore
2
1512
by: Thiago Guedes | last post by:
Hi, how can I open a .hlp file by a link in a asp.net page? *** <asp:hyperlink id="HyperLink1" runat="server" NavigateUrl="help/help.HLP">Help</asp:hyperlink> **** When the link open I dont...
0
1298
by: Madmax | last post by:
I am trying to use the .hlp file (an old help from for an existing app) in my application .Although the file shows up but it does not open the desired search string this is what I am doing ...
2
1585
by: vijesh purbia | last post by:
I am not able to run a help file(.hlp format) in vb.net 2005 .So please help me regarding the issue. OS-XP-PROFESSIONAL PLATFORM-VB.NET 2005 thanks & regards vijesh purbia
2
1753
by: HornyAZNBoy | last post by:
I've just wrote a hlp file to a program I just completed. Now I want to open that hlp file with a command on my program. I've tried using the Call Shell(C:/WINDOWS/Cris/desktop/MS Skill Book/Skill...
2
1366
jkmyoung
by: jkmyoung | last post by:
Does anyone know of good software to create a windows help file? .hlp There seems to be tons out there, but the ones lately I've tried so far aren't that great. Looking for both free and...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.