Jump to content

Recommended Posts

Posted

Boas malta.... 👍

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?

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

Posted

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
Posted

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...

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.