How to tell my code to look in a specific folder?
Dim folder As VDF.Vault.Currency.Entities.Folder = conn.WebServiceManager.DocumentService.GetFolderByPath("$/Designs/sub1/sub2/sub3/")
No folder.name or folder.path?
Also I see many instances where the SDK says specify a folderID. Can someone enlighten me as to what it actually wants?
Hi,
What function are you using that needs a folder? Does it take a Folder Id? If so, is using the Id property of the Folder not a solution?
This is usually the approach I see, get the folder using something like are you are and then using the ID property. (or something FileIteration.FolderId)
Thanks,
Wayne
Hi Wayne.
I am looking at different approaches to a larger problem and trying to fumble my way through the SDK.
In the samples there is one that passes in the folder root object. I dont want to do this so was hoping to loop through (get) files in a sub folder.
Please spell it out for me if you could in vb preferably.
Hi,
The VaultList sample from the SDK might get you started. The 'PrintFilesInFolder' procedure in this sample is recursive.
Private Sub PrintFilesInFolder(parentFolder As VDF.Vault.Currency.Entities.Folder, connection As VDF.Vault.Currency.Connections.Connection) ' get all the Files in the current Folder. Dim childFiles As File() = connection.WebServiceManager.DocumentService.GetLatestFilesByFolderId(parentFolder.Id, False) ' print out any Files we find. If childFiles IsNot Nothing AndAlso childFiles.Any() Then For Each file As File In childFiles ' print the full path, which is Folder name + File name. Me.m_listBox.Items.Add((Convert.ToString(parentFolder.FullName) & "/") + file.Name) Next End If ' check for any sub Folders. Dim folders As IEnumerable(Of VDF.Vault.Currency.Entities.Folder) = connection.FolderManager.GetChildFolders(parentFolder, False, False) If folders IsNot Nothing AndAlso folders.Any() Then For Each folder As VDF.Vault.Currency.Entities.Folder In folders ' recursively print the files in each sub-Folder PrintFilesInFolder(folder, connection) Next End If End Sub
Hope this helps.
It still leaves me with the same problem. How do i pass in the folder i'm interested in? What does a folderID look like?
Hi,
Is the folder you're interested in a Vault folder/path or a local folder/path? What are you trying to achieve? A folder object has some properties. One of them is the Id property, which is a long value (ex: 541).
I think the issue is the VDF folder is an Entities.Folder object but the document service method gives you back a webservices.folder object. Both reference the same Vault folder with the same ID but have different methods depending on what you want to do with the Folder. Entities are used through the VaultConnection Object. The below gets a webservices.folder and uses the ID of that to get the Entities.Folder (In VB.net)
Dim vaultWebServicesFolder As Autodesk.Connectivity.WebServices.Folder = ServiceManager.DocumentService.GetFolderByPath("$/Designs")
Dim vaultEntitiesFolder As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder = VaultConnection.FolderManager.GetFoldersByIds({vaultWebServicesFolder.Id}).First.Value
Looking for help on this subject if the post is still open. I am also trying the same scenario. Passing a specific folder to the PrintFilesInFolder sub that comes with the SDK. But having trouble. I have included a stripped down version of my code. Any help would be greatly appreciated. The two things I am struggling with are noted in red. So close yet so far away.
Yes nearly there! Its just understanding when working with the connection object, its an entity.Folder but when working with the WebServiceManager is a Webservices.Folder. The below will work without adding anymore references.
Imports System.Windows.Forms
Imports Autodesk.Connectivity.WebServices
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework
Module ConsoleApp
Sub Main()
Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("localhost", "Vault", "Administrator", "", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
If Not results.Success Then
Return
End If
Dim connection1 As VDF.Vault.Currency.Connections.Connection = results.Connection
Try
Dim Folder1 As Folder = connection1.WebServiceManager.DocumentService.GetFolderByPath("$/Work Folder/Standard Product")
'Errors here, I think I am missing a reference, maybe webservicestools which didn’t come with the SDK?
'Should be a webservices folder (Autodesk.Connectivity.WebServices.Folder) not an entitites folder,
Dim vaultEntitiesFolder As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder = connection1.FolderManager.GetFoldersByIds({Folder1.Id}).First.Value
PrintFilesInFolder(Folder1, connection1.WebServiceManager)
Catch ex As Exception
MessageBox.Show(ex.ToString(), "Error")
Return
End Try
End Sub
Private Sub PrintFilesInFolder(Folder1 As Folder, ServiceManager As WebServiceManager)
'Same as above
Dim FolderFiles As File() = ServiceManager.DocumentService.GetLatestFilesByFolderId(Folder1.Id, False)
For Each FolderFile As File In FolderFiles
Console.WriteLine(FolderFile.Name)
Next
End Sub
End Module
Thank you! This definitely got me farther but the servicemanager as webservicemanager is not working. Is it part of the "Autodesk.Connectivity.WebServicesTools"? I don't have the reference for that and it wasn't included in the SDK. Again, thank you. I really appreciate the help.
Imports Autodesk.Connectivity.WebServicesTools
Its part of the webservices reference, you should be able to add the line below to the imports at the top of your code page. A little tip, if you just type it anyway and hover over it, Visual studio will give you suggestions to resolve and it will add the import for you.