Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete API

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
allen.gager
1672 Views, 4 Replies

Delete API

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

4 REPLIES 4
Message 2 of 5
Redmond.D
in reply to: allen.gager

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.

Message 3 of 5
allen.gager
in reply to: Redmond.D

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

 

Message 4 of 5
Redmond.D
in reply to: allen.gager

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.

Message 5 of 5
allen.gager
in reply to: Redmond.D

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

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report