<%@ EnableSessionState=False LANGUAGE=VBScript %> <%Option Explicit%> <!--#include virtual="./INC/ADOVBS.asp"--> <!--#include virtual="./INC/Classes/HTMLPage.asp"--> <% Dim objFileSys,vPath Dim objRS,vFieldArray,vArray
'Get root folder.
Set objFileSys = Server.CreateObject("Scripting.FileSystemObject")
'Create and disconnect Recordset object.
Set objRS = Server.CreateObject("ADODB.Recordset")
Set objRS.ActiveConnection = Nothing
objRS.CursorType = adOpenKeyset
objRS.LockType = adLockOptimistic
objRS.CursorLocation = adUseClient
vPath = Server.MapPath("./") & "\\dirADO.xml"
If objFileSys.FileExists(vPath) Then
'Strange but true: open the persisted XML file
'and then delete it to save a new one.
Call objRS.Open(vPath,,,,adCmdFile)
objFileSys.DeleteFile(vPath)
'This technique is suggested in MS KB article Q245367.
'Note: because of this, the IIS Anonymous user must have
'Change permissions to the root documents folder.
'This creates a security hole and therefore sucks.
vFieldArray = Array("rootFolder","subFolder","fileName","fileDescription")
vArray = Array("docs","issues","file.pdf","PDF file")
Call objRS.AddNew(vFieldArray,vArray)
Call objRS.Update
Else
Call basCreateRS(objRS)
Call objRS.Open
End If
Call objRS.Save(vPath,adPersistXML)
'Clean up.
Call objRS.Close
Set objRS = Nothing
Set objFileSys = Nothing
Sub basCreateRS(objRS)
'Define Field objects.
Call objRS.Fields.Append("rootFolder",adBSTR,256,adFldMayBeNull)
Call objRS.Fields.Append("subFolder",adBSTR,256,adFldMayBeNull)
Call objRS.Fields.Append("fileName",adBSTR,256,adFldMayBeNull)
Call objRS.Fields.Append("fileDescription",adBSTR,1024,adFldMayBeNull)
End Sub
%>