FieldFileNameIncludeFullPath Property
Gets or sets whether to include the full file path name.

Namespace: Aspose.Words.Fields
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public bool IncludeFullPath { get; set; }

Property Value

Type: Boolean
Examples
Shows how to use FieldOptions to override the default value for the FILENAME field.
Document doc = new Document(MyDir + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToDocumentEnd();
builder.Writeln();

// This FILENAME field will display the file name of the document we opened
FieldFileName field = (FieldFileName)builder.InsertField(FieldType.FieldFileName, true);
field.Update();

Assert.AreEqual(" FILENAME ", field.GetFieldCode());
Assert.AreEqual("Document.docx", field.Result);

builder.Writeln();

// By default, the FILENAME field does not show the full path, and we can change this
field = (FieldFileName)builder.InsertField(FieldType.FieldFileName, true);
field.IncludeFullPath = true;

// We can override the values displayed by our FILENAME fields by setting this attribute
Assert.IsNull(doc.FieldOptions.FileName);
doc.FieldOptions.FileName = "Field.FileName.docx";
field.Update();

Assert.AreEqual(" FILENAME  \\p", field.GetFieldCode());
Assert.AreEqual("Field.FileName.docx", field.Result);

doc.UpdateFields();
doc.Save(ArtifactsDir + "" + doc.FieldOptions.FileName);
See Also