Move component to another folder

17

I want to move one component from one folder to another folder already created.

while (textReader.Read())
{
    textReader.MoveToElement();
    Component comp = tdse.GetComponent(textReader.GetAttribute("ID"), constant_Publication, true, -1);
}

I try looking for comp.Move but it doesn't exist. Also, I saw that in comp.Info.Path there is the path, but if I try to modify it I have the following error:

Error 7 Property or indexer 'Tridion.ContentManager.Interop.TDS._Info.Path' cannot be assigned to -- it is read only.

What can i do to move the component?

tridionero

Posted 2013-03-14T13:23:15.140

Reputation: 343

Answers

14

It looks like you are using TOM rather than TOM.NET

You need to perform a paste action with the folder you want to get the new item into

Something like

objFolder.PasteItem(comp, 1, false)

The first parameter is the item you want to paste, the second is an enumerator (EnumTDSCutCopyAction - 1 is cut (move), 0 is copy ) to say if you want to Copy and Paste or Cut and Paste, and the final one is whether you want to assert a unique name.

In TOM.NET there is a RepositoryLocalObject.Move() method.

Chris Summers

Posted 2013-03-14T13:23:15.140

Reputation: 7 657

1I just wanted to add that you should use the enumeration (TDSDefines.EnumTDSCutCopyAction) instead of hard-coding it to "1". It won't change, but it's a good practice regardless :) – Peter Kjaer – 2013-03-18T10:49:53.470

12

in the TOM API you have this method implemented on the Folder as a paste action (in the 2011 TOM.NET API there is a Component.Move indeed).

Folder.PasteItem(ByVal Item As Variant, ByVal action As TDSDefines.EnumTDSCutCopyAction, ByVal makeUnique As Boolean)

Parameters

  • item - The TOM object or URI representing the item to be pasted.
  • action - The action to perform: cut-paste or copy-paste.
  • makeUnique - Specifies whether the title of the pasted item should be made unique within the new organizational item.

Bart Koopman

Posted 2013-03-14T13:23:15.140

Reputation: 29 724