我保存了一个可在Handler(.ashx)文件中使用的PDF文档。我使用下面的代码但是在保存之后我看到该文档说"无法加载文档"。
任何帮助将不胜感激! 提前谢谢。
WebResponse objResponse;
objResponse = WebRequest.Create("http://local/dummy.ashx").GetResponse();
byte[] ByteBucket = new byte[objResponse.ContentLength];
BinaryReader readStream = new BinaryReader(objResponse.GetResponseStream());
Int32 currentBytesRead = 0;
currentBytesRead = readStream.Read(ByteBucket, 0, Convert.ToInt32(objResponse.ContentLength));
Attachment attachDocument = new Attachment();
attachDocument.ContentType = objResponse.ContentType;
attachDocument.Name = "Terms and Conditions.pdf";
attachDocument.OwnerId = UserUtility.CurrentUserProfile.Contact.OwnerId;
attachDocument.Body = ByteBucket;