file - How To Save Attachments object to RackSpace Cloud using C#? -
i have 1 'system.net.mail.attachment[] attachment' object , object contains pdf,xls,doc or jpg file.
i want save attachment object cloud server.
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(); }
i have used above code save file. file saved cloud having 0 byte data (corrupted) file. have searched many places that. not able find error in code.
please suggest solution in case ?
looks making more difficult needed. attachment
instance has contentstream
property don't need feed through memorystream @ all.
string ssavepath = "emailattachment/" + intsomeid + "/"; string strerrormsg = string.empty; if ((attachments != null)) { cloudfilesystem.savefiletocloudsystem( attachments[inti].contentstream, ref strerrormsg, ssavepath, confighelper.privatecontainer, attachments[inti].name); }
if doing this:
memorystream memorystream = new memorystream(); streamwriter memorywriter = new streamwriter(memorystream); memorywriter.write(attachments[0]);
you writing string representation of attachment
(tostring() gets called) , not content of file.
Comments
Post a Comment