Erlang – list_dir

Erlang list_dir

In this guide, we will discuss Erlang list_dir. This method is used to list down the contents of a particular directory.

Syntax

list_dir(directory)

Parameters

  • directory − The directory for which the contents need to be listed.

Return Value

The list of items which contains the file names in the directory.

For example

-module(helloworld). 
-export([start/0]). 

start() -> 
   io:fwrite("~p~n",[file:list_dir(".")]).

Output

Depending on the contents of your current working directory, the list of files will be displayed accordingly. An example output is shown in the following program −

{ok,["helloworld.erl",".cg_conf","Newfile.txt","helloworld.beam"]}

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply