readdir([dir]) -> Vector{ByteString}

Returns the files and directories in the directory dir (or the current working directory if not given).


  1. Get files and directories in the current directory:

    julia> readdir()
    3-element Vector{ByteString}:

    This example retrieves the files and directories in the current working directory.

  2. List files and directories in a specific directory:

    julia> readdir("path/to/directory")
    2-element Vector{ByteString}:

    It lists the files and directories present in the specified directory.

  3. Handle directories with no files:
    julia> readdir("empty_directory")
    0-element Vector{ByteString}

    If the directory passed as an argument does not contain any files or directories, an empty vector is returned.

Common mistake example:

julia> readdir("non_existent_directory")
ERROR: SystemError: readdir: no such file or directory (ENOENT)

In this example, the function encounters an error because the specified directory does not exist. It's important to ensure that the directory path is accurate and valid before calling readdir.

See Also

abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: