I am looking to delete all .dwfx files that belong to a particular Category in Vault Collaboration 2011.
Does anyone have the code to do this?
Cheers,
AllenG
Solved! Go to Solution.
Solved by Redmond.D. Go to Solution.
I don't have code for you, but I can tell you how to do it.
Use DocumentService.FindFilePathsBySearchConditions to set up a search for files with a specific category name. Next, call DocumentService.DeleteFileFromFolder on all the results.
Doug,
I am using the base code from the SDK VaultFileBrowser sample.
I am unable to find DocumentService.FindFilePathsBySearchConditions.
I tried using DocumentService.FindFilesBySearchConditions instead but the result does not contain the folderId that must be passed to DocumentService.DeleteFileFromFolder.
I tried replacing it with DocumentService.FindFileFoldersBySearchConditions but I get this error:
Sorry, I must have mistyped the funciton name. FindFileFoldersBySearchConditions is the one you want.
The return type for that function is "FileFolder []" but you are trying to assign it to a variable of type "File []" so that is why you are getting a compile error.
Thank You Doug,
That did the trick.
Here is the section of code that I modified from the original VaultFileBrowser SDK code in case someone else needs it.
Note that this will cause the deleation of files without user intervention based on the search criteria.
I used the Advanced Find to filter the files with Category contains Name and File contains .DWFX
This allowed me to delete a large number of specific .DWFX files.
Dim fileList As List(Of FileFolder) = New List(Of FileFolder)()
Dim bookmark As String = String.Empty
Dim status As SrchStatus = Nothing
While (status Is Nothing OrElse fileList.Count < status.TotalHits)
Dim files As FileFolder() = m_docSvc.FindFileFoldersBySearchConditions(conditions, Nothing, Nothing, True, _
True, bookmark, status)
If (Not files Is Nothing) Then
fileList.AddRange(files)
End If
Label3.Text = fileList.Count.ToString & " of " & status.TotalHits.ToString
Me.Refresh()
End While
If (fileList.Count > 0) Then
'iterate through found files and display them in the search results list box then delete it
For Each file As FileFolder In fileList
'create the list item that will wrap the File
Dim fileItem As ListBoxFileItem = New ListBoxFileItem(file.File)
m_searchResultsListBox.Items.Add(fileItem)
' This next line will delete the File without warning
m_docSvc.DeleteFileFromFolderUnconditional(file.File.MasterId, file.Folder.Id)
Next file