Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy method?? 1

Status
Not open for further replies.

Painkiller

Programmer
May 18, 2001
97
NL
Hi all,

Is there a method to copy a file from one directory to another? I need a method without using the filesystem object or API calls.

Thanx,

Sujesh
 
You can do it in a couple of lines with an API. Any reason you want to avoid it?
 
Try this:

Option Explicit

Private Sub Command1_Click()
Dim source As String 'the path to the source file
Dim dest As String 'the path to the destination file
Dim raw As String * 256

source = "c:\notes.mdb"
dest = "c:\temp\notes.mdb"
Open source For Binary As #1
Open dest For Binary As #2

Do While Not EOF(1)
Get #1, , raw
Put #2, , raw
Loop

Close #1
Close #2
MsgBox "done"


Option Explicit

Private Sub Command1_Click()
Dim source As String 'the path to the source file
Dim dest As String 'the path to the destination file
Dim raw As String * 256 'this is a buffer, you can increase or decrease this depending on your systems ram.

source = "c:\notes.mdb"
dest = "c:\temp\notes.mdb"
Open source For Binary As #1
Open dest For Binary As #2

Do While Not EOF(1)
Get #1, , raw
Put #2, , raw
Loop

Close #1
Close #2

End Sub
Troy Williams B.Eng.
fenris@hotmail.com

 
VB has the FileCopy statement, which will allow you to do this.
 
Sorry about the last post, there is only supposed to be on sub Command1_Click



Troy Williams B.Eng.
fenris@hotmail.com

 
Thanks for your reply, but I already solved it. I needed to copy only word documents, so I solved it by using a word object. The reason that I didn't want to use API calls was that the code needed to be understandable and easy for other (novice) programmers, which API calls generally aren't.

Sujesh
 
Oops, there have been various replies while I posted the last message. Thanks Strongm for your reply. Exactly what I needed. Don't need to bother with the Word object anymore!

Sujesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top