473,405 Members | 2,261 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,405 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
Jul 21 '05 #1
8 2013
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.