God bless Reflector!! Maybe I should have tried this one earlier rather than that crappy* “Import SharePoint Solution Package” tool that led me down the garden path!!
I had been trying to add the document template file to a folder and document in the _cts folder like the “Import SharePoint Solution Package” tool (and every other blog site) was doing and linking my content type to the file and was getting nowhere.
So I decided to see how SharePoint actually does it from the ChangeContentTypeOptionalSettings.aspx page
See below is an extract from Microsoft.SharePoint.ApplicationPages.dll ChangeContentTypeOptionalSettingsPage OnSubmit UpdateContentType
The two lines of paramount importance are highlighted
HttpPostedFile file = base.Request.Files;
if ((file.FileName.Length > 0) && (file.ContentLength > 0))
string fileName = file.FileName;
fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
base.ContentType.ResourceFolder.Files.Add(fileName, file.InputStream, true);
base.ContentType.DocumentTemplate = fileName;
flag = true;
base.ContentType.DocumentTemplate = "";
flag = true;
This has resolved the issue with Word documents, I still need to find a solution for Visio documents…this is my next battle…
Thanks to all those people whom provided ideas and feedback, as always it is much appreciated!
*I am sure that the “Import SharePoint Solution Package” tool has its place…but content types and document templates it not something it does well…use with caution!