Results 1 to 7 of 7
  1. #1
    ppl2pass's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    804
    Reputation
    5
    Thanks
    111
    My Mood
    Amused

    [Vb.net] File Search?

    Basically how would you search for a file on your C drive.

    All i need is a listbox with the file path for each file found.

    Btw i need a fast method as way.
    Last edited by ppl2pass; 05-18-2010 at 10:13 PM.

  2. #2
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81


    -----------------------------------------------

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  3. #3
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    The following code will search according to the pattern given. In this case .txt files:

    [php] Dim searchAll As String = "*.*"
    Dim searchSpecific As String = "*.txt"
    For Each drive As DriveInfo In My.Computer.FileSystem.Drives
    Try
    For Each File As String In My.Computer.FileSystem.GetFiles(drive.Name, FileIO.SearchOption.SearchAllSubDirectories, searchSpecific )
    Listbox1.Items.Add (File)
    Next
    Catch ex As Exception

    'In case if a file's access is denied !!
    Continue For
    End Try
    Next[/php]

    Hope this helps !!
    Last edited by Hassan; 05-18-2010 at 11:01 PM.

  4. The Following 2 Users Say Thank You to Hassan For This Useful Post:

    Hell_Demon (05-19-2010),ppl2pass (05-19-2010)

  5. #4
    ppl2pass's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    804
    Reputation
    5
    Thanks
    111
    My Mood
    Amused
    what if i want to search for txt file called database?

  6. #5
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by ppl2pass View Post
    what if i want to search for txt file called database?
    [php] Dim searchAll As String = "*.*"
    Dim searchSpecific As String = "*.txt"
    For Each drive As DriveInfo In My.Computer.FileSystem.Drives
    Try
    For Each File As String In My.Computer.FileSystem.GetFiles(drive.Name, FileIO.SearchOption.SearchAllSubDirectories, searchSpecific )
    If system.io.path.getfilenamewithoutextension(File)=" database" Then
    Listbox1.Items.Add (File)
    End If
    Next
    Catch ex As Exception

    'In case if a file's access is denied !!
    Continue For
    End Try
    Next [/php]

  7. The Following User Says Thank You to Hassan For This Useful Post:

    ppl2pass (05-19-2010)

  8. #6
    ppl2pass's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    804
    Reputation
    5
    Thanks
    111
    My Mood
    Amused
    it doesnt work for me.

  9. #7
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    is the file name database.txt? if not then thats not gonna work ;P
    Ah we-a blaze the fyah, make it bun dem!

  10. The Following User Says Thank You to Hell_Demon For This Useful Post:

    Lolland (05-21-2010)

Similar Threads

  1. [Release] Visual Basic .NET file protector
    By dragonattak in forum Visual Basic Programming
    Replies: 21
    Last Post: 05-31-2011, 06:05 AM
  2. Problem with paint.net and moding DTX files
    By dehpwner in forum Combat Arms Help
    Replies: 6
    Last Post: 06-10-2010, 03:09 AM
  3. [Vb.net] Write folder with files from resource to..
    By ppl2pass in forum Visual Basic Programming
    Replies: 23
    Last Post: 05-29-2010, 03:08 AM
  4. World.rez File search
    By Nudsh00t_Ha in forum Combat Arms Mod Discussion
    Replies: 1
    Last Post: 05-22-2010, 02:37 AM
  5. [SOURCE CODE]Write File To Disk From Resources[VB.NET]
    By ajvpot in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 2
    Last Post: 03-30-2010, 08:54 PM