Aspose::Words::Fields::FieldFileSize::get_IsInKilobytes method
Contents
[
Hide
]FieldFileSize::get_IsInKilobytes method
Gets or sets whether to display the file size in kilobytes.
_Bool Aspose::Words::Fields::FieldFileSize::get_IsInKilobytes()
Examples
Shows how to display the file size of a document with a FILESIZE field.
auto doc = System::MakeObject<Aspose::Words::Document>(System::String(get_MyDir() + u"Document.docx"));
ASSERT_EQ(doc->get_BuiltInDocumentProperties()->get_Bytes(), 18105);
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
builder->MoveToDocumentEnd();
builder->InsertParagraph();
// Below are three different units of measure
// with which FILESIZE fields can display the document's file size.
// 1 - Bytes:
auto field = System::ExplicitCast<Aspose::Words::Fields::FieldFileSize>(builder->InsertField(FieldType::FieldFileSize, true));
field->Update();
ASSERT_EQ(field->GetFieldCode(), u" FILESIZE ");
ASSERT_EQ(field->get_Result(), u"18105");
// 2 - Kilobytes:
builder->InsertParagraph();
field = System::ExplicitCast<Aspose::Words::Fields::FieldFileSize>(builder->InsertField(FieldType::FieldFileSize, true));
field->set_IsInKilobytes(true);
field->Update();
ASSERT_EQ(field->GetFieldCode(), u" FILESIZE \\k");
ASSERT_EQ(field->get_Result(), u"18");
// 3 - Megabytes:
builder->InsertParagraph();
field = System::ExplicitCast<Aspose::Words::Fields::FieldFileSize>(builder->InsertField(FieldType::FieldFileSize, true));
field->set_IsInMegabytes(true);
field->Update();
ASSERT_EQ(field->GetFieldCode(), u" FILESIZE \\m");
ASSERT_EQ(field->get_Result(), u"0");
// To update the values of these fields while editing in Microsoft Word,
// we must first save the changes, and then manually update these fields.
doc->Save(get_ArtifactsDir() + u"Field.FILESIZE.docx");
See Also
- Class FieldFileSize
- Namespace Aspose::Words::Fields
- Library Aspose.Words for C++