cancel
Showing results for 
Search instead for 
Did you mean: 

Teamcenter SOA and C#: How to download a file?

Pioneer
Pioneer

Hi!

 

I am fresh to Teamcenter and just beginning my journey here. I have a connection open with TCUA in my code. I can few files in the system but am not sure how to use download files. I tried using WebClient and its downloading unusable 4kb files. I as well don't know how the FileManagementUtility is used to download a file from the db to my system.

 

I found a few referenced posts with very similar questions:

Soa Download File

Download file link 2

 

However, none of the answers go about explaining how to do this or link to a page that does.

 

Any help or links to pages with information on this process are greatly appreciated.

5 REPLIES

Re: Teamcenter SOA and C#: How to download a file?

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Re: Teamcenter SOA and C#: How to download a file?

Pioneer
Pioneer

So this looks like its for downloading portions of a dataset. What if I want to download a single specific file? I see DownloadFileFromPLM() & DownloadFiletoLocation().

 

I have the files Uid and Object_string properties. Rather what I should say is I don't know how to get the ImanFile.

 

When I try to obtain any of the "IMAN" properties I can see, it returns:

The IMAN_Rendering property is not loaded in the client model.

 

The other two properties are IMAN_based_on and IMAN_external_object_link.

Re: Teamcenter SOA and C#: How to download a file?

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor
All properties won't be loaded by default. You have to set a property policy (it's explained in the doc) and add the required properties in the defined policy. This can be done in code or policy xml. Sample policy xml are in %TC_DATA%\soa\policies\Default.xml

Re: Teamcenter SOA and C#: How to download a file?

Pioneer
Pioneer

I have the tc_data/soa/policies/Default.xml open, but this doesn't necessarily translate on how to do this for my c# solution. How do I set a property policy in c# via code or do I need an xml doc such as this included in the project?

Re: Teamcenter SOA and C#: How to download a file?

Pioneer
Pioneer

UPDATE TWO

Created new topic that better suited the question

 

UPDATE
Tried

FileManagementUtility fmu = new FileManagementUtility(Teamcenter.ClientX.Session.getConnection());
fmu.GetFileToLocation(stl, "C:/Users/jtth/Desktop/TestFolder/" + stl.Object_string, null, null);

Returned

Exception thrown: 'System.IO.FileNotFoundException' in TcSoaClient.dll
Exception thrown: 'System.NullReferenceException' in TcSoaClient.dll
Object reference not set to an instance of an object.