dcsimg
Results 1 to 3 of 3

Thread: Move file to different folders

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    458

    Move file to different folders

    There are three folders: A, B and C

    There are 5 files in A.

    How to code to move first file (No matter how to sort) in A to B and move the rest of 4 files to C?
    Last edited by aspfun; Jan 12th, 2018 at 03:15 PM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2017
    Posts
    671

    Re: Move file to different folders

    Please review lines 1 through 5, your syntax is way off...

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,532

    Re: Move file to different folders

    Try this
    Code:
        Private Sub MoveFiles(A As String, B As String, C As String)
            Dim files() = IO.Directory.GetFiles(A)
            If files.Length >= 5 Then
                My.Computer.FileSystem.CopyFile(files(0), IO.Path.Combine(B, IO.Path.GetFileName(files(0))))
                For j = 1 To 4
                    My.Computer.FileSystem.CopyFile(files(j), IO.Path.Combine(C, IO.Path.GetFileName(files(j))))
                Next
            End If
        End Sub



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width