CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2011
    Posts
    34

    [RESOLVED] How To Move A File From A Folder To Another Folder.

    hi
    anyone no how to pick up a file in 1 location and put it into a folder in another while deleting the old file in folder

    if the files are in different locations
    like say a c drive to an f drive

  2. #2
    Join Date
    Oct 2011
    Posts
    34

    Re: How To Move A File From A Folder To Another Folder.

    Dim FileSystemObject As Object
    Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
    FileSystemObject.CopyFile "c:\file.txt", "H:\file.txt"

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [RESOLVED] How To Move A File From A Folder To Another Folder.

    Hmm The thread says resolved but the moethod shown in post 2 will not do what is asked in post 1.

    The Vb Function for this is
    Code:
    Name PathFileName As NewPathFileName
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Oct 2011
    Posts
    34

    Re: [RESOLVED] How To Move A File From A Folder To Another Folder.

    it moves the file from the c to the h driv. i decided to leave out the delete foir now.
    do u think its wrong?
    it seem to work the moving of it from 1 location to another

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [RESOLVED] How To Move A File From A Folder To Another Folder.

    Copy is different than move, copy makes a copy it does not move the original.

    A lot of people seem to use FSO anymore, I guess that is what they have learned to use or think it is easier but it really is not the way it should be done. This is an object that was created for scripting and even though it works and can be used in VB, vb has its own methods for doing all these things and they are all faster while using less resources.

    In VB CopyFile makes a copy of a file as you have done with the FSO
    Name is used to rename or move a file
    Always use [code][/code] tags when posting code.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured