Delete API

Delete API

Anonymous
Not applicable
2,641 Views
6 Replies
Message 1 of 7

Delete API

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
2,642 Views
6 Replies
Replies (6)
Message 2 of 7

Redmond.D
Autodesk
Autodesk

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 Redmond
Software Engineer
Autodesk, Inc.

0 Likes
Message 3 of 7

Anonymous
Not applicable

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:

 

 

Error 2 Value of type '1-dimensional array of Autodesk.Connectivity.WebServices.FileFolder' cannot be converted to '1-dimensional array of Autodesk.Connectivity.WebServices.File' because 'Autodesk.Connectivity.WebServices.FileFolder' is not derived from 'Autodesk.Connectivity.WebServices.File'.

Any suggestions?

Cheers,
AllenG

 

0 Likes
Message 4 of 7

Redmond.D
Autodesk
Autodesk
Accepted solution

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.



Doug Redmond
Software Engineer
Autodesk, Inc.

0 Likes
Message 5 of 7

Anonymous
Not applicable

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

 

 

 

0 Likes
Message 6 of 7

mgrenier1
Collaborator
Collaborator

Would anyone happen to have an updated version for Vault Pro 2026?

0 Likes
Message 7 of 7

mgrenier1
Collaborator
Collaborator

Anyone?

0 Likes