List of a Vault folder's contents

List of a Vault folder's contents

Anonymous
Not applicable
3,536 Views
3 Replies
Message 1 of 4

List of a Vault folder's contents

Anonymous
Not applicable

Hi folks.  What is the best way to get a list of the files which reside within a specified Vault folder?

Ideally, I'd like to be able to limit it to just ".idw" files, but all the files would be a good start.

I have been trying some rather convoluted mechanisms which are not working out for me and feel like they are probably unnecessarily complex.

It seems like there would be a rather straight-forward way to get a listing of a folder's contents.  Just a list of strings would be fine - or File objects or whatever.  Thanks!

Best regards,
--Jeff

0 Likes
Accepted solutions (1)
3,537 Views
3 Replies
Replies (3)
Message 2 of 4

gilsdorf_e
Collaborator
Collaborator
Accepted solution

Hello, that does not seem to be a big deal in the Vault SDK.

 

 

 public List<String> getFilesInVaultFolder(DocumentService _docServ, String _folderPath)
        {


            Folder searchFolder = _docServ.GetFolderByPath(_folderPath);

            File[] fileArray = _docServ.GetLatestFilesByFolderId(searchFolder.Id, true);

            List<String> fileNames = fileArray.Select(x => x.Name).ToList();

            return fileNames;

        }

 If you only use IDW and not IPN or Inventor DWG, you could use

  public List<String> getFilesInVaultFolder(DocumentService _docServ, String _folderPath)
        {


            Folder searchFolder = _docServ.GetFolderByPath(_folderPath);

            File[] fileArray = _docServ.GetLatestFilesByFolderId(searchFolder.Id, true);

            List<String> fileNames = fileArray.Where(y=>y.FileClass == FileClassification.DesignDocument).Select(x => x.Name).ToList();

            return fileNames;

        }

to only get the IDWs. Otherwise it is a bit more tricky and involves either the PropertyService or you need a search with FindFilesBySearchCondition().

 

 

 

 

Message 3 of 4

Anonymous
Not applicable

Thank you very much, Erik!  That worked great.

For anyone who might find this and be using VB.NET, the similar LINQ expressions portion would be like this:

Dim filenames As List(Of String) = Nothing

'(All files in folder)
filenames = fileArray.[Select](Function(x) x.Name).ToList

'(IDW's only)
filenames = fileArray.Where(Function(y) y.FileClass = ACW.FileClassification.DesignDocument).[Select](Function(x) x.Name).ToList


Best regards,
--Jeff

0 Likes
Message 4 of 4

i.rudd
Contributor
Contributor

Hello,

 

You can also get the information to excel without the need of using any code:

 

1) In Vault: open folder of interest

2) Select column(s) of interest

3) Press Ctrl+c

4) Open an excel sheet and press Ctrl+v