Erlang - list_dir 方法

该方法用于列出特定目录的内容。

语法

list_dir(directory)

参数

  • directory − 需要列出其内容的目录。

返回值

包含目录中文件名的项目列表。

例如

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

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

输出

根据当前工作目录的内容,将相应地显示文件列表。 以下程序显示了示例输出 −

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

❮ erlang_file_input_output.html