Hi Radek,
I really appreciate your help but this doesn't work. I have tried it before and I tried it again and it still failing. I will explain what I think the reason is.
First, I am following what is in here (http://devnet.kentico.com/docs/6_0/devguide/documents_api_examples_managing_documents.htm).
This is the code:
// Fill dataset with documents
DataSet documents = tree.SelectNodes(CMSContext.CurrentSiteName, "/API-Example/%", "en-us", false, "CMS.MenuItem");
if (!DataHelper.DataSourceIsEmpty(documents))
{
// Loop through all documents
foreach (DataRow documentRow in documents.Tables[0].Rows)
{
// Create a new Tree node from the data row
TreeNode editDocument = TreeNode.New(documentRow, "CMS.MenuItem", tree);
string newName = editDocument.DocumentName.ToLower();
// Change coupled data
editDocument.SetValue("MenuItemName", newName);
// Change document data
editDocument.DocumentName = newName;
// Save to database
editDocument.Update();
return true;
}
}
The problem is this is not what I need. It is basically copying a document to another one with the
same type. What I don't know is how to change the type. I tried:
TreeNode editDocument = TreeNode.New(documentRow, "CMS.MyNewTypeHere", tree);
but then it destroyed some of the references to the original file, didn't create the new one and now I ended up with something like this:
http://farm9.staticflickr.com/8252/8555330814_31dede5324_b.jpgBTW, I can't even remove this document anymore. "Right click -> Delete" doesn't work.
Thanks!