Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 17th, 2004, 09:49 AM
Authorized User
Join Date: Dec 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to search whole disk for .doc files?

I want to make a function that will search c:\ for doc files and show them in list view(2 collums one for the name of document and the other for directory info of the document)

blabla.doc C:\documents

Old February 17th, 2004, 12:00 PM
Registered User
Join Date: Nov 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts


this is a recursive function that search in a specified path.
it returns an arrayList of paths, you can put it in a listbox after.
see that you don't have UnauthorizedAccessException.

calling the function:

Dim results As ArrayList = searchDirectory("c:\", "*.doc")

Private Function searchDirectory(ByVal path As String, ByVal filetype As String) As ArrayList
        Dim arr As New ArrayList

        Dim dirs As String() = Directory.GetDirectories(path)
        Dim dir As String
        For Each dir In dirs
            arr.AddRange(searchDirectory(dir, filetype))

        Dim files As String() = Directory.GetFiles(path, filetype)
        Dim file As String
        For Each file In files
        Return arr
    End Function

hope it helps.

Old February 18th, 2004, 09:25 AM
Authorized User
Join Date: Dec 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts

yeah helped thank you very much

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uploading Large Files to a Doc Lib viccoleman SharePoint Admin 1 May 15th, 2006 01:13 PM
how to copy date from doc files jitendersingal General .NET 0 February 13th, 2006 07:19 AM
import .doc files text in access jf17 Access 1 December 10th, 2003 03:58 PM
Restoring Files from a Disk Device Bob Bedell SQL Server 2000 2 October 5th, 2003 06:33 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.