File.size

ulong size() @property @safe

Returns the size of the file in bytes, ulong.max if file is not searchable or throws if the operation fails. Example:

import std.stdio, std.file;

void main()
{
    string deleteme = "delete.me";
    auto file_handle = File(deleteme, "w");
    file_handle.write("abc"); //create temporary file
    scope(exit) deleteme.remove; //remove temporary file at scope exit

    assert(file_handle.size() == 3); //check if file size is 3 bytes
}