//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingGrapeCity.Documents.Word; namespaceDsWordWeb.Demos{// This sample loads an existing document, and replaces// the (only) image in it with a different one.publicclassReplaceImage {publicGcWordDocumentCreateDocx() {// The new image data:var picBytes = File.ReadAllBytes(Path.Combine("Resources", "ImagesBis", "DianeForsyth.jpg")); // Load the document:var doc = newGcWordDocument(); doc.Load(Path.Combine("Resources", "WordDocs", "ProcurementLetter.docx")); // Access the image to replace:var pic = doc.Body.Sections.First.GetRange().Pictures.First;// Replace the image data in place: pic.ImageData.SetImage(picBytes, "image/jpeg"); // Done:return doc; } }}