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: 

acquire file to specific folder and maintain folder structure

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
wangdu
1108 Views, 6 Replies

acquire file to specific folder and maintain folder structure

I am trying to acquire file to a specific folder (non-working folder) using the AcquireSettings. It works but it doesn't maintain the folder structure. Here is my code.

private AcquireFilesSettings GetSettings(string path)
		{
			var settings = new AcquireFilesSettings(_vaultServices.Connection)
			settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = true;
			settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = true;
			settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeLibraryContents = true;
			settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption =
				Autodesk.DataManagement.Client.Framework.Vault.Currency.VersionGatheringOption.Latest;
                        settings.LocalPath = new FolderPathAbsolute(path);
                        settings.OrganizeFilesRelativeToCommonVaultRoot = true;
			return settings;
		}


public void DownloadAssembly(VDF.Vault.Currency.Entities.FileIteration topLevelAssembly)

{
        var settings = GetSettings(@"C:\Temp\local");
            settings.AddFileToAcquire(fileIteration, AcquireFilesSettings.AcquisitionOption.Download);
VDF.Vault.Results.AcquireFilesResults results = _vaultServices.Connection.FileManager.AcquireFiles(settings); }

 

 How can I make sure it maintains the folder structure. I have used the 'settings.OrganizeFilesRelativeToCommonVaultRoot = true' but it didn't do what it says it would.

 

In case this doesn't work, would it be possible to perform such downloads maintaining the folder structure using the old webservice (low level) way?

 

6 REPLIES 6
Message 2 of 7
Vladimir.Ananyev
in reply to: wangdu

Very similar attached procedure works on my side.

Could you please test it with your data?

Cheers,

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 7
wangdu
in reply to: Vladimir.Ananyev

I've tested your procedure but it still doesn't create the intermediate folders relative to the root.

 

my file is at the location, say, $\Design\Source\File\test.dwg

my target directory is "c:\temp\bbb\ddd"

 

I would like that the result of downloading will be "c:\temp\bbb\ddd\Design\Source\File\test.dwg". Is this supported using the AcquireFileSettings?

 

Thanks

 

Message 4 of 7
Vladimir.Ananyev
in reply to: wangdu

AcquireFilesSettings.LocalPath property defines the target folder for download operation.

If you need in path "c:\temp\bbb\ddd\Design\Source\File\test.dwg" then AcquireFilesSettings.LocalPath property should be defined as "c:\temp\bbb\ddd\Design\Source\File".

System.IO.Directory.CreateDirectory method could help you to create all directories and subdirectories in the specified path unless they already exist.

 

Regards,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 7

I thought the property 'AcquireFilesSettings.OrganizeFilesRelativeToCommonVaultRoot' would help. Here is the excerpt from the vault sdk documentation:

 

 

public System.bool OrganizeFilesRelativeToCommonVaultRoot {get; set;}

Remarks

If True, then if the local path is c:\temp and the files are $\Foo\file1.txt and $\Bar\file2.txt, then the files will be downloaded in c:\temp\Foo\file1.txt and c:\temp\Bar\file2.txt

If False, then if the local path is c:\temp and the files are $\Foo\file1.txt and $\Bar\file2.txt, then the files will be downloaded in c:\temp\file1.txt and c:\temp\file2.txt

 

Are there someone who could clarify a bit on this please?

 

Thank you

 

Message 6 of 7
smithmat
in reply to: COOLORANGE

The setting really only makes any difference when dealing with multiple files.  In your sample code, you are only dealing with one file, so the “common vault root” for all files in a set of one will be the containing directory.  I.e. in this case the common vault root will be $/Designs/Front Loader/Parts/.  This means that it won’t use any of that path in the final local path, so the results you are seeing are expected.

 

If you used multiple files, like in the SDK documentation, what happens is it figures out the common part of the vault path for all the files and *doesn't* use that as part of the local path, but does use any remaining (non-common) part of the path.  In the SDK example, the only common root part of the path is $/, so that is not very enlightening. An additional example to help would be if you were using the following files:

$/Foo/Bar/A.txt and

$/Foo/Other/B.txt

$/Foo/Bar/Sub/C.txt

 

Here, the "Common Vault Root" would be $/Foo/.  So, if the LocalPath was set to C:\temp\, the files would end up as 

C:\temp\Bar\A.txt

C:\temp\Other\B.txt

C:\temp\Bar\Sub\C.txt

 

Unfortunately, there is no way to specify what you *want* the "common Vault root" to be (i.e. if in the example above you wanted Foo to be part of the local path in the end, you couldn't do that without having some file that didn't live in the Foo directory) it is always determined automatically.

 

Hope that helps,

- Matt

Message 7 of 7
wangdu
in reply to: smithmat

I test with multiple files, as you described, and it worked perfectly. I have misread the documentation and now it is clear enough. I appreciate it and thank you very much, Matt. 

 

Regards,

Wangdu

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

Post to forums  

Autodesk Design & Make Report