Any idea why a call to AddAttachment would not return any error but also not seem to actually add the image I am trying to add to a "File" type column on a custom document type?
I am using this version of the method:
DocumentHelper.AddAttachment(TreeNode node, String guidColumnName, String file, TreeProvider tree)
node = the TreeNode of the custom document type I am trying to add an image to.
guidColumnName = name of the column containing the Attachment GUID (Defined as File data type for this custom document type)
file = attachment file path (actual path to the image file on the web server that I am trying to attach (I verify its existance first by calling File.Exists)
tree = treeProvider to use
Here is my full code if that helps:
private bool insertTeacherMainImage(string pUsername, string pImage, ref string statMsg)
CMS.DocumentEngine.TreeProvider dp = new CMS.DocumentEngine.TreeProvider(ui);
CMS.DocumentEngine.TreeNode teacherDoc = dp.SelectSingleNode(siteName, TEACHER_DIRECTORY_ALIASPATH + "/" + pUsername, cultureCode, true, TEACHER_CUSTOM_CLASS_NAME);
if (teacherDoc != null)
pImage = PATH_TO_TEACHER_IMAGES + pImage;
//insert link under teacher's document
CMS.DocumentEngine.DocumentHelper.AddAttachment(teacherDoc, "MainImage", pImage, dp);
catch (Exception ex)
// if we get here, the teacher document did not exist!
This code returns true so it is finding the TreeNode, finding the image on the server that I want to add, and the call to AddAttachment does not raise an error. Is there some other step, like a "save" or "update" method I need to call as well as the AddAttachment?