SharePoint 2010 upload Office 2010 document using stream -


i upload document sharepoint 2010 document library using asp fileupload control.

the process works fine office 92-2003 documents, txt, rtf , pdf until meets office 2010 documents.

the problem is: can upload file successfully. file there on sharepoint server. after downloading local, open file show file has unreadable content (or corrupt) , need recover read. after recovering, opens normally. xlsx file

i recall reading somewhere office 2010 documents uploading stream different office 2003 don't remember how is.

this code:

aspx

<asp:fileupload id="uploadcontrol" runat="server" onchange="filechooseaction()" /> 

code behind

dim byt byte() redim byt(uploadcontrol.postedfile.inputstream.length) uploadcontrol.postedfile.inputstream.seek(0, seekorigin.begin) uploadcontrol.postedfile.inputstream.read(byt, 0, uploadcontrol.postedfile.inputstream.length) uploadcontrol.postedfile.inputstream.close() 

i found out because of 1 byte byte array. right code should

dim byt byte() redim byt(uploadcontrol.postedfile.inputstream.length - 1) uploadcontrol.postedfile.inputstream.seek(0, seekorigin.begin) uploadcontrol.postedfile.inputstream.read(byt, 0, uploadcontrol.postedfile.inputstream.length - 1) uploadcontrol.postedfile.inputstream.close() 

it seems office 2010 documents run trouble byte (by design?). pdf, office 97-2003 , others aren't.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -