1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

File search problem

Discussion in 'Visual Basic ( VB )' started by Iona, Jan 11, 2009.

  1. Iona

    Iona New Member

    Joined:
    Sep 30, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Hi.

    This is my first time here and i am hoping to get some help with some of my problems?

    I am learning to program in vb 2008 and have a problem with some code.
    I am trying to search a drive for any .Wav files, the problem i am having is that after a while i get a denied error on some folders which i can seem to resolve. :nonod:

    Also the code in bold i can seem to get to work properly either and would be grateful for any help with this.



    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Browse_Click[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]sender[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]System[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]e[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]System[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Browse[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Click
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]ListBox1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Items[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Clear[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]()
    [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]ListBox1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]EndUpdate[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]()
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE][/COLOR][/SIZE] 
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]FolderBrowserDialog1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]ShowDialog[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]() = [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]DialogResult[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]OK[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]strFile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Computer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]FileSystem[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]GetFiles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](([/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]FolderBrowserDialog1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]SelectedPath[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]), [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Microsoft[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]VisualBasic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]FileIO[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]SearchOption[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]SearchAllSubDirectories[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"*.wav"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE][/COLOR][/SIZE] 
    [B][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Regex[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]IsMatch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]strFile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"*.wav"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][/SIZE][B][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]ListBox1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Items[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Add[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]Computer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]FileSystem[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]GetName[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]strFile[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]))[/B]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][B]Else[/B]
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#020002][SIZE=2][COLOR=#020002]MsgBox[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"No Wav files located"[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B])[/B]
    
    [/SIZE][B][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
    [/COLOR][/SIZE][/COLOR][/SIZE]

    Many thanks

    worf
     

Share This Page