Hello guys. I'm doing a project now. I'm having a problem on getting specific file type from my computer using the .getfiles function.
Here's my codes.
Private Sub dlgOpen_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgOpen.FileOk Dim filepath as String = "C:\" dlgOpen.CheckFileExists = True txtOpen.Text = dlgOpen.FileName sizetext = "MB" If System.IO.Directory.Exists(filepath) Then Dim myDir As New System.IO.DirectoryInfo(filepath) For Each myFile As System.IO.FileInfo In myDir.GetFiles("*.mp3") Me.lblFname2.Text = myFile.FullName.ToString() Me.lblFtype.Text = myFile.Extension.ToString() Me.length = ((myFile.Length.ToString / 1024) / 1024) Me.length = Format(length, "0.00") Me.lblsize2.Text = length & " " & sizetext Next End If End Sub
What I wanted to happen is when the openfiledialog prompted and once I've selected the file, the file information I've specified above must show on the application as a label. But nothing appears. The file name only appears on the text box beside the open button. It should also appear above the button and the text box as a label. How could i possibly do that? And how could I select just one file at a time from a folder with 150 other files in it? When I use getFiles, it only gets all at the same time everything that's in the folder even if i've only just selected one file.
I'm hoping for someone kind to answer my query. This is for the sake of our thesis project at school. Thanks! More power!