Here is my current code, and it works fine to choose one image and copy it, however, I cannot figure out how to allow multiple file selections then copy them to a new folder.

Please help!

Imports System.IO
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strFileName As String
        Dim Export As String 'filename only
        Dim I As Integer 'variable used for counting
        Dim DidWork As Integer = OpenFD.ShowDialog() 'for use below in calculating
        OpenFD.InitialDirectory = "c:\imagetest\" 'sets initial directory for user to choose files
        strFileName = OpenFD.FileName 'sets file name to the variable strFileName

        'If user pushes cancel before selecting file this error displays
        If DidWork = DialogResult.Cancel Then
            MsgBox("Aw snap!  You clicked cancel!")
            MsgBox(strFileName) 'show a messagebox with the file selected
        End If

        Export = Path.GetFileName(strFileName) 'sends only the filename and extension to the variable export

        If strFileName = "" Then
        ElseIf Export = "" Then
            FileCopy(strFileName, "c:\flexihotfolder\" & Export) 'copies file to specified folder

        End If

    End Sub
End Class

Recommended Answers

All 3 Replies

See if this helps.

OpenFD.Multiselect = True '// Allow Multiple File Selections.
        If OpenFD.ShowDialog = DialogResult.OK Then
            For Each selFile As String In OpenFD.FileNames
                MsgBox(selFile) '// Show FullPath of File.
        End If

Will this allow all of the files to be copied to the new directory as well?

Replace the "MsgBox(selFile) '// Show FullPath of File.)" with this.

Export = Path.GetFileName(selFile) 'sends only the filename and extension to the variable export
        FileCopy(selFile, "c:\flexihotfolder\" & Export)
commented: AWESOME! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.