Using ADO Record to Create and Navigate Intranet Files and Folders - Copying files from one folder to another (Page 6 of 6 )
Although only copying is shown in the next code listing, it is also possible to move and delete (at your own risk) files and folders as well. Copying requires defining source and destination as well as what needs copying, as shown in the pop-up help.

Option Compare Database
Private rec As ADODB.Record
Private rec2 As ADODB.Record
Private Sub Command0_Click()
Set rec = New ADODB.Record
'open the file location
rec.Open "", "URL=http://hodentek/DevHome/ASPFree/"
MsgBox ("Rec is open" & rec.State)
'copy from ASPFree folder to DevShed folder with the overwrite flag.
rec.CopyRecord "http://hodentek/DevHome/AspFree", _
"http://hodentek/DevHome/DevShed", , , adCopyOverWrite
rec.Close
End Sub
The result of this copying is shown in the next picture.

Summary
ADO is a powerful tool and should be in your arsenal if you are working with the VB 6 environment. The Record object confers considerable power to ADO. Great caution must be exercised while moving or deleting folders in the web site as there may be other dependencies to be considered such as links. Pay careful attention to the Options argument in the syntax for all objects. When an XLS file is created, as shown in the tutorial, you could open the file with the Excel application. Also for the XLS file-type, overwriting may result in an error as the Excel program by default may not allow overwriting, and care should be exercised.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |