Hello everyone !!!

I recently designed a web application using VB.Net and tried to copy a folder (containing multiple files) from one disk drive to another but unfortunately I didn't succeed.
I tried using a file upload but that is only for single/multiple file selection however I want to select a complete folder instead of multiple files.
Please help if anyone knows as it is a real urgent task for me to accomplish.

Thank you very much in advance.

Recommended Answers

All 4 Replies

Do you mean something like this?

    Try
        Dim myDir As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "/tmpOldLoc/"
        Dim toDir As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "/tmpNewLoc/"


        If Directory.Exists(myDir) = True Then
            Dim di As New IO.DirectoryInfo(myDir)
            Dim diar1 As IO.FileInfo() = di.GetFiles()
            Dim dra As IO.FileInfo
            For Each dra In diar1
                File.Copy(dra.FullName, toDir & dra.Name)
            Next
        End If

    Catch ex As Exception

        MsgBox("Something went wrong!" & vbCrLf & ex.Message)

    End Try

Thanks a lot Begginnerdev.

Np friend, anything else I can help you with?

Not for now I guess, thanks again :)

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.