473,503 Members | 11,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Spider Function Update

Herfried K. Wagner wrote this function but it only walks one level of
subfolders. How do you update this function so that if it finds all
sub directory files and returns the result like this:

Example of what I need:
Folder A
File 1
File 2
Folder SubA
File 1
File 2

Return to look like this:

File1
File2
SubA\File1
SubA\File2


Herfried Code:

Private Function GetFilesAsFileInfo( _
ByVal strPath As String, _
ByRef astrPatterns As String() _
) As ArrayList
Dim di As DirectoryInfo = New DirectoryInfo(strPath)
Dim al As New ArrayList()
Dim s As String
Dim afi As FileInfo()
Dim fi As FileInfo
For Each s In astrPatterns
afi = di.GetFiles(s)
For Each fi In afi
al.Add(fi)
Next fi
Next s
Return al
End Function
End Module

Nov 21 '05 #1
2 954
Is this what you want ... pass path without ending back slash

Private Sub GetFilesAsFileInfo(ByVal strPath As String, ByRef astrPatterns
As String(), ByRef al As ArrayList)

Dim di As DirectoryInfo = New DirectoryInfo(strPath)

'Dim al As New ArrayList

Dim afi As FileInfo()

For Each s As String In astrPatterns

afi = di.GetFiles(s)

For Each fi As FileInfo In afi

al.Add(fi)

Trace.WriteLine(fi.FullName)

Next fi

Next s

For Each di2 As DirectoryInfo In di.GetDirectories

GetFilesAsFileInfo(strPath & "\" & di2.Name, astrPatterns, al)

Next

End Sub

HTH

rawCoder

"pmclinn" <pm*****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Herfried K. Wagner wrote this function but it only walks one level of
subfolders. How do you update this function so that if it finds all
sub directory files and returns the result like this:

Example of what I need:
Folder A
File 1
File 2
Folder SubA
File 1
File 2

Return to look like this:

File1
File2
SubA\File1
SubA\File2


Herfried Code:

Private Function GetFilesAsFileInfo( _
ByVal strPath As String, _
ByRef astrPatterns As String() _
) As ArrayList
Dim di As DirectoryInfo = New DirectoryInfo(strPath)
Dim al As New ArrayList()
Dim s As String
Dim afi As FileInfo()
Dim fi As FileInfo
For Each s In astrPatterns
afi = di.GetFiles(s)
For Each fi In afi
al.Add(fi)
Next fi
Next s
Return al
End Function
End Module

Nov 21 '05 #2
So I finally got this working (This is the general idea and I'm open to
suggestions to improve this code:
Private Sub GetFilesAsFileInfo(ByVal strPath As String)
Dim al As New ArrayList
'al.Add(strPath)
Dim di As DirectoryInfo = New DirectoryInfo(strPath)
For Each diLooper As DirectoryInfo In di.GetDirectories
al.Add(diLooper.FullName)
Console.Out.WriteLine(diLooper.Name)
GetFilesAsFileInfo(diLooper.FullName)
Next
End Sub

Then I pass the directories into Herfried code:
Herfried Code:

Private Function GetFilesAsFileInfo( _
ByVal strPath As String, _
ByRef astrPatterns As String() _
) As ArrayList
Dim di As DirectoryInfo = New DirectoryInfo(strPath)
Dim al As New ArrayList()
Dim s As String
Dim afi As FileInfo()
Dim fi As FileInfo
For Each s In astrPatterns
afi = di.GetFiles(s)
For Each fi In afi
al.Add(fi)
Next fi
Next s
Return al
End Function
End Module


Nov 21 '05 #3

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

Similar topics

4
7985
by: Kyle Mizell | last post by:
I am looking for a script that I can use to spider a website, and then pull the images... I know how to do it for a single page, but, I would like to be able to do this for the entire site. Any...
0
2371
by: Auction software | last post by:
Free download full version , all products http://netauction8.url4life.com/ Groupawy --------------- Google Groups Email spider. The first email spider for google groups. Millions of valid...
3
3216
by: Thomas Lindgaard | last post by:
Hello I'm a newcomer to the world of Python trying to write a web spider. I downloaded the skeleton from http://starship.python.net/crew/aahz/OSCON2001/ThreadPoolSpider.py Some of the...
0
1415
by: Laszlo Zsolt Nagy | last post by:
Hi All, I'm writting a spider program. I need to go to serveral URLs and extract information from the HTML source. Including links. I was using FancyURLOpener and my own function that extracts...
0
2008
by: Auction software | last post by:
Free download full version , all products from Mewsoft dot com http://netauction8.url4life.com/ Groupawy --------------- Google Groups Email spider. The first email spider for google groups....
0
2062
by: dtsearch | last post by:
New release expands-through a .NET Spider API, to Linux, and to OpenOffice-dtSearch's ability to index over a terabyte of text in a single index, with indexed search time typically less than a...
3
2380
by: Tony Lance | last post by:
Big Bertha Thing spider Cosmic Ray Series Possible Real World System Constructs http://web.onetel.com/~tonylance/spider.html Access page JPG 11K Image Astrophysics net ring Access site...
2
3418
by: =?Utf-8?B?Q2hhcnRz?= | last post by:
I have been writing C# programs to spider yellow page to get list of restaurant name, address to the database. When I encounter button or hyperlink, I don’t know how to use the program to click...
0
7070
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
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
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
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
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,...
1
4993
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...
0
3160
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
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
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 ...

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.