std.stdio.File struct

This lesson teaches how to use the file struct from the std.stdio module.

The std.file module

The std.file module contains functions and types that are useful when working with the contents of directories. For example, exists can be used to determine whether a file or a directory exists on the file system. It takes a string as an argument, which specifies the name of the file.

import std.file; // ...
  if (exists(fileName)) {
      // there is a file or directory under that name
  } else {
      // no file or directory under that name
  }

Below is the code implementing the concepts discussed so far:

Get hands-on with 1200+ tech skills courses.