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