Disable the document-template for a list via code (DocumentTemplateUrl)

A current requirement was to disable the DocumentTemplateUrl for a SPList-instances. So the “New document” does not appear anymore inside the list.

The trick

So there is no such property available in the SPList-class which allows us to disable the DocumentTemplateUrl. In order to “get the property” we need to cast the object.

// web was declared earlier
SPDocumentLibrary docLib = (SPDocumentLibrary) web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, "Lists/doclib"));
docLib.DocumentTemplateUrl = string.Empty;
docLib.Update();

Thats it.