We don't have inbuilt function to sort Site Templates based on size hence we will get random size site templates. When we do auto upgrade site template it may cause the issue because random order.


I found the solution please check below.

SPWebApplication spWebApp = this.WebApplication;
//get all quota templates
SPWebService contentService = SPWebService.ContentService;
SPQuotaTemplateCollection quotaTemplates = contentService.QuotaTemplates;
//Sorting quota templates
List<SPQuotaTemplate> _sortQuotaTemplates = sortQuotaTemplates(quotaTemplates);

private List<SPQuotaTemplate> sortQuotaTemplates(SPQuotaTemplateCollection quotaTemplates)
            List<SPQuotaTemplate> _quotaTemplatesList = new List<SPQuotaTemplate>();

            foreach (SPQuotaTemplate item in quotaTemplates)

            _quotaTemplatesList.Sort((x, y) => x.StorageMaximumLevel.CompareTo(y.StorageMaximumLevel));

            return _quotaTemplatesList;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.