How To Copy Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Talihomz
    New Member
    • Jan 2008
    • 11

    How To Copy Files

    Hi.I jus wanted to know how i can make a program that copies files from one location to another without deleting the original file.
  • creative1
    Contributor
    • Sep 2007
    • 274

    #2
    Hi
    In order to do this yo need to design a form using DirList box and DriveListBox to select source and destination store source and destination address in two textboxes call text1 and text2. Another label can be used to tell user about successful completetion of the process.

    then use follwoing code

    Dim fso As New Scripting.FileS ystemObject
    fso.CopyFolder Text1.Text, Text2.Text, True
    Label1.Caption = "backup created successfully at " + Text2.Text

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Try to use Scripting.FileS ystemObject

      Comment

      • creative1
        Contributor
        • Sep 2007
        • 274

        #4
        I forgot to tell add Microsoft Scripting Runtime in reference.

        Kind Regards

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Of course, you could just use the built-in FileCopy statement. At least, if your version of VB has one. I know VB6 does, don't know about later versions.

          Comment

          • jamesd0142
            Contributor
            • Sep 2007
            • 471

            #6
            this works so play around with it:

            [code=vbnet]
            Private Sub Copy()
            'access denied to startup path
            Dim dest1 As String = "C:\a\a\text.tx t"
            If System.IO.File. Exists(dest1) = False Then
            Dim origional As String = "C:\a"
            System.IO.File. Copy(origional & "\text.txt" , dest1)
            End If
            End Sub
            [/code]

            Thanks James

            Comment

            Working...