Free Support Forum - aspose.com

Saving new document to Sharepoint

Hi,

The problem I'm having is trying to save a document into Sharepoint, I can save the file to sharepoint but when I open it all I get is unrecognisable characters. If I save the newly created doc to a network fine then the word doc opens up fine. The code i'm using is:

MemoryStream stream = new MemoryStream();

//Save document to memorystream

docMain.Save(stream, SaveFormat.Doc);


SPSecurity.RunWithElevatedPrivileges( delegate()

{

SPWebsite=new SPSite ("http://sharepoint/0ebbd4beaaa9dd118a3e001111014c61/test.doc").OpenWeb();

byte[] contents = new byte[stream.Length];

stream.Read(contents, 0, (int)stream.Length);
stream.Close();

site.AllowUnsafeUpdates = true;

site.Files.Add ("http://sharepoint/0ebbd4beaaa9dd118a3e001111014c61/test.doc", contents);

});

Thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Maybe you should try using the following code to get file bytes.

byte[] content = stream.GetBuffer();

Hope this helps.

Best regards.

Thanks for your help, that has done the trick :slight_smile:

Hi!

We are delighted to announce the availability of Aspose.Words for SharePoint, which is our latest addition to the Aspose.Words product family.

This release, Aspose.Words for SharePoint 1.0 makes high quality document conversions for DOC/DOCX/ODT/RTF/PDF/XPS and others easily accessible to SharePoint users.

Please find more details in our Documentation area.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(14)