我有一个'System.Net.Mail.Attachment []附件'对象,该对象包含PDF,Xls,Doc或jpg文件。如何使用C#将附件对象保存到RackSpace Cloud?
我想将此附件对象保存到云服务器。
string sSavePath = "EmailAttachment/" + intSomeid + "/";
string strErrorMsg = string.Empty;
if ((attachments != null))
{
MemoryStream memoryStream = new MemoryStream();
StreamWriter memoryWriter = new StreamWriter(memoryStream);
memoryWriter.Write(attachments[0]);
memoryStream.Position = 0;
CloudFileSystem.SaveFileToCloudSystem(memoryStream, ref strErrorMsg, sSavePath, ConfigHelper.PrivateContainer, attachments[intI].Name);
memoryWriter.Dispose();
memoryStream.Dispose();
}
我已经使用上面的代码来保存文件。 文件被保存到云,但有0字节数据(损坏)的文件。 我搜索了很多地方。 但无法找到代码中的错误。
请在这种情况下建议一些解决方案?
谢谢您的回答。 '附件[intI] .ContentStream'是我最初尝试过的。这也是用0B保存文件。所以问题不是解决这个问题。请进一步帮助我 – ParthKansara