473,654 Members | 3,108 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 GetFilesAsFileI nfo( _
ByVal strPath As String, _
ByRef astrPatterns As String() _
) As ArrayList
Dim di As DirectoryInfo = New DirectoryInfo(s trPath)
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 964
Is this what you want ... pass path without ending back slash

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

Dim di As DirectoryInfo = New DirectoryInfo(s trPath)

'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.GetDirectori es

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

Next

End Sub

HTH

rawCoder

"pmclinn" <pm*****@gmail. com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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 GetFilesAsFileI nfo( _
ByVal strPath As String, _
ByRef astrPatterns As String() _
) As ArrayList
Dim di As DirectoryInfo = New DirectoryInfo(s trPath)
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 GetFilesAsFileI nfo(ByVal strPath As String)
Dim al As New ArrayList
'al.Add(strPath )
Dim di As DirectoryInfo = New DirectoryInfo(s trPath)
For Each diLooper As DirectoryInfo In di.GetDirectori es
al.Add(diLooper .FullName)
Console.Out.Wri teLine(diLooper .Name)
GetFilesAsFileI nfo(diLooper.Fu llName)
Next
End Sub

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

Private Function GetFilesAsFileI nfo( _
ByVal strPath As String, _
ByRef astrPatterns As String() _
) As ArrayList
Dim di As DirectoryInfo = New DirectoryInfo(s trPath)
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
8008
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 suggestions? Thanks, Kyle Mizell http://www.pimpinonline.com
0
2380
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 and active emails in one easy location to collect. Spiderawy
3
3225
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 source shown below. A couple of questions:
0
1422
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 the links from a HTML page. The problem is that I always need to change it. This is because some sites use lower case tag names, others upper case tag names. Some of them use href="page.html" others do it without the quotation href=page.html but...
0
2020
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. Millions of valid and active emails in one easy location to collect. Spiderawy
0
2074
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 second BETHESDA, MD (January 10, 2006) dtSearch Corp., a leading supplier of enterprise and developer text retrieval software, announces Version 7.2 of its product line for instantly searching terabytes of documents across a desktop, network,...
3
2390
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 Newsgroup Reviews including uk.rec.cycling Drawing of a clockwork spider wheel and hairpin.
2
3430
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 the button or hyperlink. Does anyone have this type of sample code in either C#, vb.net? Thanks, Charts
0
8376
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8708
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8594
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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 we have to send another system

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.