Free Support Forum -

Image File cannot be written to the Disk

I have a scenario where I need to return a byte array. This is the code that was used with the earlier version(5.2.2.). As I said earlier, I have to use both the version as I have some users who are not ready for this upgrade. For the user who are ready with this upgrade, I’m using Aspose.Words ver 8.2.1.

The below strategy is used in my middle tier and changing the UI peice is very very risky. Appreciate your help.

The new version errors out when I use the new version. Here the code and error:

public byte[] PdfStream
System.Security.Principal.WindowsImpersonationContext ctx = RemoveASPNETAuthenticationToken();

MemoryStream memStream = new MemoryStream();
Document.Save(memStream, SaveFormat.AsposePdf);

memStream.Seek(0, SeekOrigin.Begin);
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
Aspose.Pdf.Pdf pdf = new Pdf();
pdf.BindXML(xmlDoc, null);
byte[] byteStream;
using (MemoryStream pdfStream = new MemoryStream())

byteStream = pdfStream.ToArray();
return byteStream;
// Resume impersonation
if (ctx != null) ctx.Undo();

I’m getting the Error “Image File cannot be written to the Disk…” when I use this method. How can I solve this with the new version of Word.


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

Thanks for your request. To fix this problem you should just specify folder where images will be saved. Please see the following link for more information:

Also, with the new version of Aspose.Words you can use direct method of PDF conversion (without Aspose.Pdf and saving in intermediate format). Please see the following link to learn more:

Best regards.