Jump to content
Tim§id€

Procurar qualquer tipo de ficheiro?

Recommended Posts

Tim§id€

Boas malta.... :thumbsup:

Gostaria que me dessem uma ajuda!= algum sabe se existe no VB algum comando para poder tipo numa inputbox o utilizador introduza a extensão tipo *.MP3 ou *.WMA....e depois vai procurar no Computador todos os ficheiros com essa extensão?


...º(>_<)º...

Share this post


Link to post
Share on other sites
jpaulino

Olá,

Podes fazer algo do género:

    Sub ListFiles(ByVal strRootPath As String, ByVal filePattern As String)
        Try

            Dim FullDir() As String = IO.Directory.GetDirectories(strRootPath)
            For Each Dir As String In FullDir

                Try
                    Dim FullFiles() As String = IO.Directory.GetFiles(Dir, filePattern, IO.SearchOption.AllDirectories)
                    For Each File As String In FullFiles

                        Try

                            ' Mostra qual é o ficheiro
                            Debug.WriteLine(File)

                        Catch ex As Exception
                        End Try
                    Next

                Catch ex As Exception
                End Try
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try

    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call ListFiles("d:\", "*.mp3")
        ' Se quiseres procurar por mais ficheiros é só copiar
    End Sub

Share this post


Link to post
Share on other sites
Tim§id€

Olá,

Podes fazer algo do género:

    Sub ListFiles(ByVal strRootPath As String, ByVal filePattern As String)
        Try

            Dim FullDir() As String = IO.Directory.GetDirectories(strRootPath)
            For Each Dir As String In FullDir

                Try
                    Dim FullFiles() As String = IO.Directory.GetFiles(Dir, filePattern, IO.SearchOption.AllDirectories)
                    For Each File As String In FullFiles

                        Try

                            ' Mostra qual é o ficheiro
                            Debug.WriteLine(File)

                        Catch ex As Exception
                        End Try
                    Next

                Catch ex As Exception
                End Try
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try

    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call ListFiles("d:\", "*.mp3")
        ' Se quiseres procurar por mais ficheiros é só copiar
    End Sub

Obrigado pela ajuda...vou ver se consigo...


...º(>_<)º...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.