Free Support Forum - aspose.com

How to check file format before and after doc got change

Hi I want to check file format before and after format change, how i cna do, i just see one property . originalloadformat , but no property to see after change , what type format , is any property which tell us what type both format before and after.

MemoryStream stream = new MemoryStream();

// create the letter, writing it to the stream

letter.CreatePackage(stream);

// Convert to byte array for saving to database

byte[] byteArray = stream.ToArray();

//Docx to Doc Conversion

Aspose.Words.SaveFormat outputFormat = Aspose.Words.SaveFormat.Doc;

Aspose.Words.Document doc = new Aspose.Words.Document(stream);

// here i want to see doc.format doc.originalformat

Aspose.Words.ProtectionType protectionType = doc.ProtectionType;

doc.Save(stream, outputFormat);

// here i want to see doc.format

and is there way to open this file in same format which got change.

Hi

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

Thanks for your request. I think in this case you can use DetectFileFormat method.

Please see the following link to learn more:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.document.detectfileformat_overloads.html

Best regards,

Hi Andre,

Thanks for reply, but i am getting inputformat as unknown, what i am doing wrong, below is code snippest

MemoryStream stream = new MemoryStream();

// create the letter, writing it to the stream

letter.CreatePackage(stream);

//Docx to Doc Conversion

Aspose.Words.SaveFormat outputFormat = Aspose.Words.SaveFormat.Doc;

Aspose.Words.Document doc = new Aspose.Words.Document(stream);

Aspose.Words.ProtectionType protectionType = doc.ProtectionType;

doc.Save(stream, outputFormat);

// Convert to byte array for saving to database

byte[] byteArray = stream.ToArray();

doc = new Aspose.Words.Document(stream);

LoadFormat inputFormat = Aspose.Words.Document.DetectFileFormat(stream);

MessageBox.Show(inputFormat.Tostring());

infact if i run this code also inputformat as unknown

<A href="https://forum.aspose.com/t/93444</A></P>

infact this code input format showing unknown

<A href="https://forum.aspose.com/t/93444</A></P>

Hi AndreyN

I found way to check both format, here code snippest

MemoryStream stream = new MemoryStream();

stream.Write(mydata, 0, mydata.Length);

string extension = string.Empty;

SaveFormat outputFormat = SaveFormat.Doc;

Aspose.Words.Document doc = new Aspose.Words.Document(stream);

Aspose.Words.ProtectionType protectionType = doc.ProtectionType;

doc.Save(stream, outputFormat);

//Check format

MessageBox.Show(doc.OriginalLoadFormat.ToString());

Aspose.Words.Document doc1 = new Aspose.Words.Document(stream);

MessageBox.Show(doc1.OriginalLoadFormat.ToString());

Hi

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

It is perfect, that you already resolved the problem.

Best regards,