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.htm
廣告

© . All rights reserved.