Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ms dynamics crm 2011中输入压缩PDF文件作为附件?_C#_Pdf_Dynamics Crm_Dynamics Crm 2011 - Fatal编程技术网

C# 如何在ms dynamics crm 2011中输入压缩PDF文件作为附件?

C# 如何在ms dynamics crm 2011中输入压缩PDF文件作为附件?,c#,pdf,dynamics-crm,dynamics-crm-2011,C#,Pdf,Dynamics Crm,Dynamics Crm 2011,我为一个客户工作,该客户要求在MS Dynamics CRM中上载6MB文件。客户端具有要在Dynamics CRM中上载的.pdf、.csv文件。现在,如果我们可以在上传到Dynamics CRM之前压缩这些文件,这将很好地工作。 我试图通过使用下面的代码来修复这个需求。 这是工作和压缩文件,但当我们下载附件的那一刻,我们能够看到弹出的消息 我们无法打开此文件xxx.pdf文件,因为我们发现了一个问题 与它的内容 if(entity.Attributes.Contains(“document

我为一个客户工作,该客户要求在MS Dynamics CRM中上载6MB文件。客户端具有要在Dynamics CRM中上载的.pdf、.csv文件。现在,如果我们可以在上传到Dynamics CRM之前压缩这些文件,这将很好地工作。 我试图通过使用下面的代码来修复这个需求。 这是工作和压缩文件,但当我们下载附件的那一刻,我们能够看到弹出的消息

我们无法打开此文件xxx.pdf文件,因为我们发现了一个问题 与它的内容

if(entity.Attributes.Contains(“documentbody”))
{
字符串字节=entity.Attributes[“documentbody”].ToString();
tracingService.Trace(“CompressImagePlugin:{0}”,“交叉尝试块第一行”+字节.Length);
byte[]Uncompressedtext=Convert.FromBase64String(字节);
if(entity.Attributes.Contains(“filename”)&&entity.Attributes[“filename”]!=null
&&(entity.Attributes[“filename”].ToString()
.Contains(“.pdf”)| | entity.Attributes[“filename”].ToString()
.Contains(“.docx”))
{
tracingService.Trace(entity.Attributes[“filename”].ToString());
字节[]compress=CompressZip(解压缩文本);
字符串压缩数据=Convert.tobase64字符串(压缩);
entity.Attributes[“documentbody”]=压缩数据;
}

}
由于要将文件类型从PDF更改为ZIP,因此还需要更新附件的文件名和mimetype。大概是这样的:

entity.Attributes["filename"] = entity.Attributes["filename"].ToString().Replace(".pdf", ".zip");
entity.Attributes["mimetype"] = "application/zip";

现在,当用户单击附件时,应提示他们下载包含PDF文件的ZIP文件。

您好,我正在使用下面给定的代码,但没有获得正确格式的附件文件。