File.size

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

struct File
@property @safe
ulong
size
()

Examples

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
}

Meta