C# Folder list

Trying to get an array of folder names available from Teamcenter during user session?

The Wrapper method is:

uf.ListFolderContents(tag folder, count, Tag[] folder_contents)

Need help with the above wrapper method? What is a tag folder?

A "tag" is a type defined in the NX API; it acts as an identifier for many of the objects used in the API. If you look in the API reference guide (.net_ref.chm), you need to pass three parameters to the .ListFolderContents method. The first parameter is the tag of the folder you are interested in. The second parameter is an integer variable ("count" in the example code you posted); you pass in this parameter as "ref" and the .ListFolderContents function will change the value. The third parameter is an array of "tags"; create an empty array of type "tag" and pass it in as "ref". The function will allocate the tags of all the folders and files to the array.

Some more functions that may be useful:

  • .AskRootFolder - returns a tag of the current user's default folder
  • .AskUserFolder - returns a tag of the specified user's default folder
  • .AskObjectType - after using .ListFolderContents, iterate through the returned results with .AskObjectType. It will tell you if the returned tag belongs to a folder object, a part, or something else.
  • .AskFolderName - If you have the tag of a folder (using the function above), this will tell you the name of the folder.