DocumentVersionsCount Property
Gets the number of document versions that was stored in the DOC document.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 20.1
public int VersionsCount { get; }

Property Value

Type: Int32

Versions in Microsoft Word are accessed via the File/Versions menu. Microsoft Word supports versions only for DOC files.

This property allows to detect if there were document versions stored in this document before it was opened in Aspose.Words. Aspose.Words provides no other support for document versions. If you save this document using Aspose.Words, the document will be saved without versions.

Shows how to count how many previous versions a document has.
Document doc = new Document();

// No versions are in the document by default
// We also can't add any since they are not supported
Assert.AreEqual(0, doc.VersionsCount);

// Let's open a document with versions
doc = new Document(MyDir + "Versions.doc");

// We can use this property to see how many there are
Assert.AreEqual(4, doc.VersionsCount);

doc.Save(ArtifactsDir + "Document.Versions.docx");      
doc = new Document(ArtifactsDir + "Document.Versions.docx");

// If we save and open the document, the versions are lost
Assert.AreEqual(0, doc.VersionsCount);
See Also