GetLatest on a folder

GetLatest on a folder

rikard.nilsson
Collaborator Collaborator
626 Views
2 Replies
Message 1 of 3

GetLatest on a folder

rikard.nilsson
Collaborator
Collaborator

Hi,

 

I'm trying to do my first Vault program in a long time.

What I'm trying to do is to preform a GetLastest on a folder.

 

I have added a VaultBrowserControl and there picked a folder.

I then thought that I caould use "AddEntityToAcquire".

You can see my test below that I can't get to work.

 

Can anyone lead me in the right direction to solve my GetLastest on a folder?

And it would be perfect if I then could get the local path that was created with GetLatest to use later in my program to save my files to..

 

Regards

Rikard

 

 

***************************************************************

 

Vault.Currency.Entities.Folder foundFolder { get; set; }

 

 

Vault.Settings.AcquireFilesSettings settings = new Vault.Settings.AcquireFilesSettings(m_conn);

settings.AddEntityToAcquire(foundFolder);

Vault.Results.AcquireFilesResults results = m_conn.FileManager.AcquireFiles(settings);

***************************************************************

 

0 Likes
Accepted solutions (1)
627 Views
2 Replies
Replies (2)
Message 2 of 3

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi Rikard,

 

I did a quick test with this SDK sample:

C:\Program Files (x86)\Autodesk\Autodesk Vault 2016 SDK\vs12\CSharp\VaultBrowserSample

 

With  a few edits it was able to download all the files from a folder. (they were the latest versions). Below are the changes I made. Maybe you could update that sample to show what the problem is you are getting. Also explain where the error occurs and what it is.

 

public partial class Form1 : Form
    {
        #region Member Variables
        //WB made public and static
        //private Vault.Currency.Connections.Connection m_conn = null;
        public static Vault.Currency.Connections.Connection m_conn = null;

 

...

 

void m_model_SelectedContentChanged(object sender, Forms.Currency.SelectionChangedEventArgs e)
        {
            //when the selected content changes, we need to update the filename field to reflect the selected entities
            List<Vault.Currency.Entities.IEntity> selectedEntities = new List<Vault.Currency.Entities.IEntity>(e.SelectedEntities);

           // bool fileSelected = false;
            //WB testing - so I can run the Open command with a folder selected
            bool fileSelected = true;

 

...

 

 

 private void OpenFile()
        {
           //WB testing - running a new function that downloads a folder
            Vault.Currency.Entities.Folder fldr = m_model.SelectedContent.FirstOrDefault() as Vault.Currency.Entities.Folder;
            string folderPath = System.IO.Path.Combine(Application.LocalUserAppDataPath, "WB_Test");
            OpenFileCommand.downloadFile_WB(m_conn, fldr, folderPath);
            return;
            //WB end

 

 

  //WB added
  //     private static void downloadFile_WB(VDF.Vault.Currency.Connections.Connection connection, VDF.Vault.Currency.Entities.Folder fldr) //, string folderPath)
       public static void downloadFile_WB(VDF.Vault.Currency.Connections.Connection connection, VDF.Vault.Currency.Entities.Folder fldr, string folderPath)
       {
           VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection);
           settings.AddEntityToAcquire(fldr);
           settings.LocalPath = new VDF.Currency.FolderPathAbsolute(folderPath);
           connection.FileManager.AcquireFiles(settings);
       }
       //WB end added

 

...

 

 

Thanks,

Wayne

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

rikard.nilsson
Collaborator
Collaborator

Thanks Wayne! 

 

I did not have settings.localPath.. That did the trick..

 

/Rikard

0 Likes