FileBase.this

Opens or creates a file by name. By default, an existing file is opened in read-only mode.

  1. this(const(char)[] name, FileFlags flags)
    struct FileBase
    this
    (
    const(char)[] name
    ,
    FileFlags flags = FileFlags.readExisting
    )
  2. this(Handle h)

Parameters

name const(char)[]

Path to the file to open.

flags FileFlags

How to open the file.

Examples

// Create a brand-new file and write to it. Throws an exception if the
// file already exists. The file is automatically closed when it falls
// out of scope.
auto f = File("filename", FileFlags.writeNew);
f.write("Hello world!");

Meta