Vault Customization

Vault Customization

Reply
Valued Contributor
dominiekvanwest
Posts: 81
Registered: ‎11-27-2006
Message 1 of 5 (325 Views)
Accepted Solution

File Associations at AddFile

325 Views, 4 Replies
06-26-2012 07:15 AM

Hi,



I want to add a file to the Vault that has an attachment. So I first add the attachment and then I want to add the file with an association to the attachment. I use the following code:

 

WebServicesByteArray.Bytes = System.IO.File.ReadAllBytes(LibrarymapLocal & "Test.ipt.dwf")

serviceManager.DocumentService.AddFile(folder.Id, Test.ipt.dwf", "", System.IO.File.GetLastWriteTime(LibrarymapLocal & "Test.ipt.dwf"), Nothing, Nothing, DocumentService.FileClassification.None, True, WebServicesByteArray)

WebServicesByteArray.Bytes = System.IO.File.ReadAllBytes(LibrarymapLocal & "Test.ipt")

Dim Association(0) As Autodesk.Connectivity.WebServices.FileAssocParam

Association(0).CldFileId = fileId

Association(0).ExpectedVaultPath = Librarymap

Association(0).Typ = AssociationType.Attachment

serviceManager.DocumentService.AddFile(folder.Id, "Test.ipt", "", System.IO.File.GetLastWriteTime(LibrarymapLocal & "Test.ipt"), Association, Nothing, DocumentService.FileClassification.None, False, WebServicesByteArray)



But I get an error (System.NullReferenceException) at: Association(0).CldFileId=fileId

What am I doing wrong? What's the correct way to add a file with an attachment? (The (0) is there because it has to be an array)

 

Thanks in advance!

 

Dominiek



You declared the array, but you need to create a new object to fill it.  Try adding the following line:

 

Association(0) = new Autodesk.Connectivity.WebServices.FileAssocParam()

Employee
Redmond.D
Posts: 814
Registered: ‎12-12-2006
Message 2 of 5 (322 Views)

Re: File Associations at AddFile

06-26-2012 08:40 AM in reply to: dominiekvanwest

You declared the array, but you need to create a new object to fill it.  Try adding the following line:

 

Association(0) = new Autodesk.Connectivity.WebServices.FileAssocParam()



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Valued Contributor
dominiekvanwest
Posts: 81
Registered: ‎11-27-2006
Message 3 of 5 (314 Views)

Re: File Associations at AddFile

06-27-2012 12:23 AM in reply to: Redmond.D

Thank you for your quick reply.

This does it!

Just wondering, if the array contains more than 1 element, I'll need to do this for every item in the array? So something like this:

For i as Integer = 0 to Association.Length - 1

     Association(0) = new Autodesk.Connectivity.WebServices.FileAssocParam()

Next i



Employee
Redmond.D
Posts: 814
Registered: ‎12-12-2006
Message 4 of 5 (308 Views)

Re: File Associations at AddFile

06-27-2012 04:24 AM in reply to: dominiekvanwest

Correct.  Except your would use Association(i) inside the loop, not Association(0)



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Valued Contributor
dominiekvanwest
Posts: 81
Registered: ‎11-27-2006
Message 5 of 5 (305 Views)

Re: File Associations at AddFile

06-27-2012 04:28 AM in reply to: Redmond.D

Oh, yeah, off course with i instead of 0. Just typed it in here without checking :smileyhappy:

 

Thank you very much for the help!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.