473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Nov 20 '05 #1
4 1009
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

Nov 20 '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
Nov 20 '05 #3
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

Nov 20 '05 #4
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
Nov 20 '05 #5

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

Similar topics

0
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
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
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
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
by: xzzy | last post by:
How is a .HLP help file displayed from a C# winforms application? Thank you, John Bickmore
2
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
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
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
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
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
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.