By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

How To Copy Files

P: 11
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.
Jan 11 '08 #1
Share this Question
Share on Google+
5 Replies

P: 274
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.FileSystemObject
fso.CopyFolder Text1.Text, Text2.Text, True
Label1.Caption = "backup created successfully at " + Text2.Text
Jan 11 '08 #2

Expert 5K+
P: 8,127
Try to use Scripting.FileSystemObject
Jan 11 '08 #3

P: 274
I forgot to tell add Microsoft Scripting Runtime in reference.

Kind Regards
Jan 11 '08 #4

Expert 5K+
P: 8,434
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.
Jan 11 '08 #5

P: 469
this works so play around with it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Copy()
  2.         'access denied to startup path
  3.         Dim dest1 As String = "C:\a\a\text.txt"
  4.         If System.IO.File.Exists(dest1) = False Then
  5.             Dim origional As String = "C:\a"
  6.             System.IO.File.Copy(origional & "\text.txt", dest1)
  7.         End If
  8.     End Sub
Thanks James
Jan 11 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.