• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1094
  • Last Modified:

OpenFileDialog Multiple files GET Name, Extension and path

I have a simple question.

I have set the OpenfileDialog.Multiple = true

Now I need to iterate through the Selected files and save the File NAme, Extension and full Path to a table.

Please see code below.

IN the following approach : I can iterate and get only the Path/File Name or extansion.

How can I iterate and get all the three fields.
OpenFileDialog1.ShowDialog()
        Dim file As String
        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            For Each file In OpenFileDialog1.FileNames

                ds.Tables("Temp").Rows.Add(file,(File Name),(Extension))

            Next
            GridControl1.DataSource = ds.Tables("Temp")
        End If

Open in new window

0
isaackhazi
Asked:
isaackhazi
3 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try something like:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            For Each file As String In OpenFileDialog1.FileNames
                ds.Tables("Temp").Rows.Add(New Object() {file, System.IO.Path.GetFileNameWithoutExtension(file), System.IO.Path.GetExtension(file)})
            Next
            GridControl1.DataSource = ds.Tables("Temp")
        End If
    End Sub

Open in new window

0
 
sachinpatil10dCommented:
Use

Imports System.IO

and add this line

ds.Tables("Temp").Rows.Add(Path.GetFullPath(file), Path.GetFileName(file), Path.GetExtension(file))
0
 
vipin_softCommented:
Use this:-

 ds.Tables("Temp").Rows.Add(file, IO.Path.GetFileNameWithoutExtension(file), IO.Path.GetExtension(file))
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now