This function reads a file name and returns an array of bytes.
It can throw a FileException, if the file does not exist (anymore) or can not be read.
Example:
import std.stdio;
import std.file;
int main(char[][] args)
{
char[] content;
try
{
content = cast(char[])read(args[1]);
writefln(content);
}
catch (FileException xy)
{
writefln();
writefln("A file exception occured: " ~ xy.toString());
}
catch (Exception xx)
{
writefln();
writefln("An exception occured: " ~ xx.toString());
}
return 0;
}
|
See also:
FileException,
exists,
isfile,
write,
append,
remove,
rename
|