Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copying and Moving Subdirectories (VB)

    Hi, all.

    I'm writing a little application that will (among other things) allow someone to create a folder on a share.

    The basic approach needs to be as follows: 1) Create the folder within another specific folder (in order for the new folder to inherit the properties and permissions of the parent); then 2) move the folder to the proper location. (Trust me when I say that it's necessary to create it in a location other than it's ultimate destination.)

    My problem is that I (apparently) don't know how to copy folders using VB! I need to use the UNC-name for the folder, because I can't trust that people will have a drive letter mapped to it. I'm able to create the folder (and a necessary sub-folder), but when I try to use the FileCopy method to move it to it's ultimate resting place, I get a File Access Error 75; it does not like the FileCopy command. I'm debugging and stepping through the code when the error arises, so I know it's not because someone else has the folder open. I have read/write permissions to that share, so it's not like I don't have the right access.

    So... can someone educate me as to how I can move a folder in VB? (I though this would be so easy!)
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Copying and Moving Subdirectories (VB)

    If I were using the FileSystemObject (from VBScript) I would use Folder.Copy because it apparently differentiates between files and folders. Not sure about the older VB methods or Windows API functions.

  3. #3
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying and Moving Subdirectories (VB)

    Have you tried Name "oldpathname" As "newpathname" ?
    This works for me, including subdirectory, and both with UNC and mapped driveletter.

  4. #4
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying and Moving Subdirectories (VB)

    Excellent. Thank you both. (Sure beats calling a batch file!)
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

Posting Permissions

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