如何使用 C# 代码在 Dynamics CRM 中获取附件的阻止文件扩展名和最大文件大小

how to get blocked file extensions and maximum file size for attachment in dynamics crm using c# code

我想获取管理员在 c# 代码中设置的附件的阻止文件扩展名和最大文件大小。下图显示了我使用 c# 代码实际想要的内容。

请建议我回答。

请使用以下代码获取System Settings中的任何属性。

var query = new QueryExpression("organization")
          {
                ColumnSet = new ColumnSet("blockedattachments", "maxuploadfilesize")

           };
           EntityCollection orgCollection = _service.RetrieveMultiple(query);
           if (orgCollection.Entities.Count > 0)
           {
           Entity org = orgCollection.Entities.First();
           string blockedattachments = org.GetAttributeValue<string>("blockedattachments");
           int numberMaxUploadFileSize = org.GetAttributeValue<int>("maxuploadfilesize");
           }

尝试使用下面的代码,它已经过测试并且工作正常。

 var  query = new QueryExpression("organization")
                {
                    ColumnSet = new ColumnSet("blockedattachments", "maxuploadfilesize")
                };
                var record = service.RetrieveMultiple(query).Entities.FirstOrDefault();

                if (record != null)
                {
                    var blockedAttachments = record.GetAttributeValue<string>("blockedattachments");
                    var maxAttachmentSize = record.GetAttributeValue<int>("maxuploadfilesize");
                }