Using ADO Record to Create and Navigate Intranet Files and Folders - Adding files to folders
(Page 4 of 6 )
In this section files will be added to the folders created. It is essential to understand the nature of files and folders as described in the links cited in the tutorial. Again the code in the following paragraph is attached to a button click event on a form. Although the creation of folders and files were shown in two separate snippets, all of this can be contained in a single snippet to create folders and files all at once. Observe the usage of enums, adCreateCollection and adCreateNonCollection in the folder/file creation process.
Option Compare Database
Private rec As ADODB.Record
Private rst As ADODB.Recordset
Private Sub Command0_Click()
Set rec = New ADODB.Record
'Open the DevHome/AspFree folder
rec.Open "DevHome/ASPFree", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateCollection
rec.Close
'create a Test.htm file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.htm", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'create a Test.xls file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.xls", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'create a Test.BMP file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.bmp", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'create a Test.aspx file in the ASPFree folder
rec.Open "DevHome/ASPFree/Test.aspx", _
"URL=http://hodentek/", , _
adCreateOverwrite + adCreateNonCollection
rec.Close
'adCreateOverwrite and adCreateNonCollection etc can be added
End Sub
This creates the files in the ASPFree folder as shown in the next picture.

Since these are also created in the root directory they will be found in C:InetpubwwwrootDevHomeASPFree as shown in the next picture.

Next: Navigating the files and folders >>
More Database Articles
More By Jayaram Krishnaswamy