Results 1 to 5 of 5

Thread: Help with copying Text files

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    Help with copying Text files

    HI All

    I would like some help please on copying a folder of text files to a users choice of drive using shell explore maybe and when they select the drive and folder
    it copies the text files to that location.

    Kind Regards

    steve

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Help with copying Text files

    What sort of user interface would you like to use (TextBox, InputBox(), Browse For Folder, etc.) ?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    Re: Help with copying Text files

    @bonnie

    Hi at the moment I got a command button that is creating
    the text files I want to bring up
    windows Explorer and choose the S: drive
    Which is our server and then the user choose the folder
    Within the s: drive to copy them too

    Regards
    Steve

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: Help with copying Text files

    Steve
    If you desire, you can use the fso and two dirlistboxes instead of an explorer browser.
    Example (Will need references to FSO)
    Code:
    Private Sub Command1_Click()
    
    Dim fs As FileSystemObject
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.CopyFolder Dir1.Path, Dir2.Path, True
    
    End Sub
    The user can select the source path with Dir1, and the target path with Dir2. You would want to put in checks in case the dir (dir2) the user wants does not exist, then he she can create it with the fso as well. And as the overwrite is set to true in my example, you may want other checks as well.

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Help with copying Text files

    The attached frmCopyFiles lets a user select text files (via an Open dialog box) that will be copied to the folder chosen through a Browse For Folder dialog box. A progress dialog box is shown while copying the files.


    Name:  Screenshot.png
Views: 75
Size:  6.3 KB
    Attached Files Attached Files
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

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