Vault API - Get folders and files

This forum is now locked, since Gold Support is no longer offered.

Moderator: SourceGear

Locked
ISBE
Posts: 11
Joined: Thu May 20, 2004 7:50 am

Vault API - Get folders and files

Post by ISBE » Fri May 28, 2004 10:28 am

This is the code I have which does not work. I think I'm close. What I would like it to do is get a list of files from the selected folder and all sub folders for the vault project folder that the user has selected.

Private Sub Proc_FillGrid()
Dim lstrSelSys As String

lstrSelSys = "$/" & cboSysList.Text

Dim searchFolder As VaultClientOperationsLib.VaultClientFolder = gobjClientDev.Repository.Root.FindFolderRecursive(lstrSelSys)
Dim ReturnArray As ArrayList = New ArrayList() ' = VaultClientOperationsLib.VaultClientFolder(searchFolder)
RecursivelySearchForFileName(searchFolder, "", ReturnArray)
End Sub



Private Sub RecursivelySearchForFileName(ByVal Folder As VaultClientOperationsLib.VaultClientFolder, ByVal filename As String, ByVal Arraylist As ArrayList)
Dim SubFolder As VaultClientOperationsLib.VaultClientFolder
Dim SubFile As VaultClientOperationsLib.VaultClientFile
Dim ReturnArray As ArrayList = New ArrayList()

If Folder.Files Is Nothing Then
For Each SubFile In Folder.Files
If filename = "" Then
ReturnArray.Add(SubFile)
Else
If SubFile.Name = filename Then
ReturnArray.Add(SubFile)
Exit For
End If
End If
Next
End If
If Folder.Files Is Nothing Then
For Each SubFile In Folder.Files
RecursivelySearchForFileName(SubFolder, filename, ReturnArray)
Next
End If
End Sub


Thank you

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Fri May 28, 2004 1:15 pm

I think that the only thing that is not right is your test for Folders and Files against Nothing

You have

Code: Select all

If Folder.Files Is Nothing Then
But you need to have

Code: Select all

If Not Folder.Files Is Nothing Then


Same goes for Folder.Folders.

Locked