tridiontridion2009

Tridion - Move component to another folder


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 exits. 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?


Solution

  • 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.