Blog

Multiple File Transfer One Location To Another Location VB.Net

By Amit Sanandiya Oct 22 2012
This Code for change file location to any another location.
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 6.5k
  • 0
Multiple File Transfer One Location To Another Location VB.Net

This Code for change file location to any another location.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        Dim FSO, SourceFolder, OrderFiles, SourcePath, DestinationPath, FolderName
        Dim Counter, CounterLimit
        FSO = CreateObject("Scripting.FileSystemObject")
        SourcePath = "D:\SplitImage\"
        DestinationPath = "D:\SplitImage\test"
        'set the folder in that we have to search the files
        SourceFolder = FSO.GetFolder(SourcePath)
        'get all the Files into the variable OrderFiles
        OrderFiles = SourceFolder.Files
        'File not Exist then File Creation
        If Not FSO.FolderExists(DestinationPath) Then
            FolderName = FSO.CreateFolder(DestinationPath)
        End If
        'Set the counter limit to the number of files that we want to transfer at one go.
        CounterLimit = 50
        Counter = 1
        'Loop for transfer files one by one
        For Each Orderfile In OrderFiles
            If Counter > CounterLimit Then
                Exit For
            End If
            FSO.MoveFile(SourcePath & "\" & Orderfile.Name, DestinationPath & "\")
            Counter = CInt(Counter) + 1
        Next
    End Sub