Gets the data type of the property.
Example
Enumerates through all built-in and custom properties in a document using indexed access.
[C#]
string fileName = MyDir + "Properties.doc";
Document doc = new Document(fileName);
Console.WriteLine("1. Document name: {0}", fileName);
Console.WriteLine("2. Buil-in Properties");
for (int i = 0; i < doc.BuiltInDocumentProperties.Count; i++)
{
DocumentProperty prop = doc.BuiltInDocumentProperties[i];
Console.WriteLine("{0}({1}) : {2}", prop.Name, prop.Type, prop.Value);
}
Console.WriteLine("3. Custom Properties");
for (int i = 0; i < doc.CustomDocumentProperties.Count; i++)
{
DocumentProperty prop = doc.CustomDocumentProperties[i];
Console.WriteLine("{0}({1}) : {2}", prop.Name, prop.Type, prop.Value);
}[Visual Basic]
Dim fileName As String = MyDir & "Properties.doc"
Dim doc As Document = New Document(fileName)
Console.WriteLine("1. Document name: {0}", fileName)
Console.WriteLine("2. Buil-in Properties")
Dim i As Integer = 0
Do While i < doc.BuiltInDocumentProperties.Count
Dim prop As DocumentProperty = doc.BuiltInDocumentProperties(i)
Console.WriteLine("{0}({1}) : {2}", prop.Name, prop.Type, prop.Value)
i += 1
Loop
Console.WriteLine("3. Custom Properties")
i = 0
Do While i < doc.CustomDocumentProperties.Count
Dim prop As DocumentProperty = doc.CustomDocumentProperties(i)
Console.WriteLine("{0}({1}) : {2}", prop.Name, prop.Type, prop.Value)
i += 1
LoopRetrieves the types and values of the custom document properties.
[C#]
Document doc = new Document(MyDir + "Properties.doc");
foreach (DocumentProperty prop in doc.CustomDocumentProperties)
{
Console.WriteLine(prop.Name);
switch (prop.Type)
{
case PropertyType.String:
Console.WriteLine("It's a string value.");
Console.WriteLine(prop.ToString());
break;
case PropertyType.Boolean:
Console.WriteLine("It's a boolean value.");
Console.WriteLine(prop.ToBool());
break;
case PropertyType.Number:
Console.WriteLine("It's an integer value.");
Console.WriteLine(prop.ToInt());
break;
case PropertyType.DateTime:
Console.WriteLine("It's a date time value.");
Console.WriteLine(prop.ToDateTime());
break;
case PropertyType.Double:
Console.WriteLine("It's a double value.");
Console.WriteLine(prop.ToDouble());
break;
case PropertyType.Other:
Console.WriteLine("Other value.");
break;
default:
throw new Exception("Unknown property type.");
}
}[Visual Basic]
Dim doc As Document = New Document(MyDir & "Properties.doc")
For Each prop As DocumentProperty In doc.CustomDocumentProperties
Console.WriteLine(prop.Name)
Select Case prop.Type
Case PropertyType.String
Console.WriteLine("It's a string value.")
Console.WriteLine(prop.ToString())
Case PropertyType.Boolean
Console.WriteLine("It's a boolean value.")
Console.WriteLine(prop.ToBool())
Case PropertyType.Number
Console.WriteLine("It's an integer value.")
Console.WriteLine(prop.ToInt())
Case PropertyType.DateTime
Console.WriteLine("It's a date time value.")
Console.WriteLine(prop.ToDateTime())
Case PropertyType.Double
Console.WriteLine("It's a double value.")
Console.WriteLine(prop.ToDouble())
Case PropertyType.Other
Console.WriteLine("Other value.")
Case Else
Throw New Exception("Unknown property type.")
End Select
Next propSee Also
DocumentProperty Class | Aspose.Words.Properties Namespace