Vikki_Purohit Vikki_Purohit - 26 days ago 18
Vb.net Question

Retrieve Data From a Folder

Hello Friends,
I am doing coding in vb.net.I have some excel files in one folder. I want that all files need to be merged in windows form application. but i want to select a folder and retrieve all files. please can anyone help me in this?

Answer

You could try something like this in your code :-

Dim fd As OpenFileDialog = New OpenFileDialog()
        fd.Title = "Select Excel File"
        'insert your drive specs here 'if specific directory is searched.
        fd.InitialDirectory = D_Drive + "\programs"
        fd.Filter = "All files (*.xls)|*.xls|All files (*.xls)|*.xls"
        fd.FilterIndex = 2
        fd.RestoreDirectory = True
        If fd.ShowDialog() = DialogResult.OK Then
            filec = fd.FileName
        End If

        If filec <> "" Then
            Shell("Excel " + filec, AppWinStyle.MaximizedFocus, True)
        End If
Comments