If you are using D2, you need to import std.stdio;:
import std.stdio;
void main(string args[])
{
auto f = File("test.txt", "w");
f.writeln("Hello, Worlds!");
}
If you use D1, the class Fileis in std.stream, and the API is slightly different:
import std.stream;
void main() {
auto f = new File("test.txt", FileMode.Out);
f.writeLine("Hello, Worlds!");
}
source
share