Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, every one
I want to search for files Have Extension (Any Extension)
The Problem is I can't Search for files any Drive I chosen,
This IS The Code.
VB
Public Class Form1
    Dim FileCount As Integer = 0
    Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click
        If Not CombxDrive.Text = Nothing Then
            ListBox1.Items.Clear()
            FileCount = 0
        End If


        For Each File In My.Computer.FileSystem.GetFiles(CombxDrive.Text, FileIO.SearchOption.SearchAllSubDirectories, Nothing)
            Dim Title As String = My.Computer.FileSystem.GetFileInfo(File).Name
            If Title.Contains(CombxDrive.Text) Then
                ListBox1.Items.Add(Title)
                FileCount = FileCount + 1
            End If
        Next
        LblFileFound.Text = FileCount And "FilesFound"


    End Sub
Posted
Updated 21-Aug-11 14:32pm
v2

In the last code When excut it msg error appear to me
like this
Here
 
Share this answer
 
v2
Comments
Alan Burkhart 21-Aug-11 19:48pm    
The image link just reopens this page. Check the href.
salah3bdelfatah 22-Aug-11 14:05pm    
Ok,This Is A Link Here[.]
Have you tried Directory.GetFiles[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900