We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem to convert doc to docx in c#

Hi , I want to convert doc to docx with Aspose.Word but it dosnt work , could u help me plz
public static byte[] ConvertDocToDocx(byte[] docContent)
{
byte[] contentDocx = null;


using (MemoryStream memoryStream = new MemoryStream(docContent))
{
Document doc1 = new Document(memoryStream);
doc1.Save(memoryStream, SaveFormat.Docx);
memoryStream.Position = 0;
contentDocx = memoryStream.ToArray();
}
return contentDocx;
;
}

https://forum.aspose.com/t/43220 plz answer me

Hi Faezeh,


Thanks for your inquiry. Please use the following code to fix this issue:

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

byte[] docBytes = File.ReadAllBytes("d:\\temp\\1.doc");

byte[] contentdocX = ConvertDocToDocx(docBytes);

File.WriteAllBytes("d:\\temp\\1.docx", contentdocX);

}

public static byte[] ConvertDocToDocx(byte[] docContent)

{

byte[] contentDocx = null;

using (MemoryStream memoryStream = new MemoryStream(docContent))

{

Document doc1 = new Document(memoryStream);

using (MemoryStream stream = new MemoryStream())

{

doc1.Save(stream, SaveFormat.Docx);

contentDocx = stream.ToArray();

}

}

return contentDocx;

}

}

}


I hope, this helps.

Best regards,