Blog

Multiple File Transfer One Location To Another Location VB.Net

Posted by Amit Patel Blogs | Visual Basic .NET Oct 22, 2012
This Code for change file location to any another location.
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
PREMIUM SPONSORS
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
Employers - Post Free Jobs
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
Employers - Post Free Jobs