我已经在使用以下代码将文件复制到 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
现在,正如标题所说,我想做同样的事情,但使用一个文件夹。我想我的问题与 Livelink 并没有真正的关系,而是更多地与处理文件夹的方式有关。是否可以在不遍历所有子文件夹/文件的情况下移动所有孩子的文件夹?我如何调整我的saveFileLL()
功能来做到这一点?
编辑:
这是另一部分代码,它允许我直接在 objId 设计的 Livelink 文件夹中创建一个文件夹。
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
不要问我为什么这样有效,我发现了它并且确实有效。对于那些想知道的人来说,objId 是 Livelink 为他的所有文件/文件夹提供的唯一 ID。
谢谢你。