我有一個'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