ApiExamples.ExDocument.DocumentByteArray C# (CSharp) Метод

DocumentByteArray() приватный Метод

private DocumentByteArray ( ) : void
Результат void
        public void DocumentByteArray()
        {
            //ExStart
            //ExId:DocumentToFromByteArray
            //ExSummary:Shows how to convert a document object to an array of bytes and back into a document object again.
            // Load the document.
            Document doc = new Document(MyDir + "Document.doc");

            // Create a new memory stream.
            MemoryStream outStream = new MemoryStream();
            // Save the document to stream.
            doc.Save(outStream, SaveFormat.Docx);

            // Convert the document to byte form.
            byte[] docBytes = outStream.ToArray();

            // The bytes are now ready to be stored/transmitted.

            // Now reverse the steps to load the bytes back into a document object.
            MemoryStream inStream = new MemoryStream(docBytes);

            // Load the stream into a new document object.
            Document loadDoc = new Document(inStream);
            //ExEnd

            Assert.AreEqual(doc.GetText(), loadDoc.GetText());
        }
ExDocument