JG Vimalan's Blog

It is all about coding!

Programmatically access the custom document library template

The following method finds the custom document library template in a sharepoint site.

 private Result GetSPDocLibTemplate(SPWeb spWeb, out SPListTemplate docLibTemplate)
            Result result = new Result();
            result.IsSuccess = false;
            docLibTemplate = null;

                SPListTemplateCollection listTemplateCollection = spWeb.Site.GetCustomListTemplates(spWeb);

                foreach (SPListTemplate template in listTemplateCollection)
                    if (template.Name.ToLower().Equals(“Expected Template Name”))
                        docLibTemplate = template;

                result.IsSuccess = true;
                return result;
            catch(Exception error)
                Log.ErrorFormat(“Error while searching for doc lib template: {0}”, error.Message);
                result.ErrorMessage = error.Message;
            return result;


September 27, 2010 - Posted by | SharePoint

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: