Erlang - list_dir


Advertisements

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"]}
erlang_file_input_output.htm
Advertisements