I'm already using the following code to copy a file to Livelink:
Public Function saveFileLL(target As Long, pathSource As String, fileName As String) As Boolean
Dim dav As New ADODB.Record
Dim files As New ADODB.Recordset
Dim objStream As New ADODB.Stream
Dim url As String
If Not Val(Nz(target, 0)) > 0 Or Not pathSource Like "*.*" Or Not fileName Like "*.*" Then
saveFileLL = False
Exit Function
End If
url = URL_LIVELINK_DAV & target
dav.Open url, , adModeReadWrite
Set files = dav.GetChildren
If Not (files.BOF And files.EOF) Then files.MoveFirst
Do Until files.EOF
If fileName Like Replace(files("RESOURCE_DISPLAYNAME"), "_", "?") Then Exit Do
files.MoveNext
Loop
If files.EOF Then
files.addnew "RESOURCE_PARSENAME", fileName
files.Update
End If
files.Close
dav.Close
objStream.Open "URL=" & url & "/" & fileName, adModeWrite
objStream.Type = adTypeBinary
objStream.LoadFromFile pathSource
objStream.Flush
objStream.Close
Set dav = Nothing
Set files = Nothing
Set objStream = Nothing
saveFileLL = True
End Function
Now, as the title says, I would like to do the same but with a folder. I guess my question isn't really related to Livelink but more to the way to handle folders in general. Is it possible to move a folder with all his children without looping through all the subfolders/files? How could I adapt my saveFileLL()
function to do so?
EDIT:
Here is another portion of code that allows me to directly create one folder into the Livelink folder designed by objId.
Public Function CreateFolderToLLFolder(ObjId As String, folderName As String, Optional getId As Boolean = False) As String
Dim davfile As New ADODB.Record
Dim davFiles As New ADODB.Recordset
Dim davDir As New ADODB.Record
Dim newDirFields(1) As Variant
Dim newDirValues(1) As Variant
newDirFields(0) = "RESOURCE_PARSENAME"
newDirValues(0) = folderName
newDirFields(1) = "RESOURCE_ISCOLLECTION"
newDirValues(1) = True
Set davDir = connection(ObjId, "")
Set davFiles = davDir.GetChildren()
If (davFiles.Supports(adAddNew)) Then
davFiles.addnew newDirFields, newDirValues
End If
davfile.Open davFiles, , adModeReadWrite
CreateFolderToLLFolder = davfile.fields("urn:x-opentext-com:ll:properties:nodeid").value
End Function
Public Function connection(ObjId As String, Optional filename As String = "") As ADODB.Record
Dim davDir As New ADODB.Record
davDir.Open filename, "URL=http://livelink-server/livelinkdav/nodes/" & ObjId & "/", adModeReadWrite, adFailIfNotExists, DelayFetchStream, "", ""
Set connection = davDir
End Function
Don't ask me why this works, I found this and it does work. objId for those wondering is the unique ID that Livelink gives to all his files/folders.
Thank you.