如何在Erlang中跨目录复制文件?

Llo*_*ice 3 erlang copy file

这有效:

1> file:copy(test.html, test1.html).
{ok,2384}
Run Code Online (Sandbox Code Playgroud)

但这不是:

2> file:copy(test.html, sites/test.html). 
   ** exception error: bad argument in an arithmetic expression
   in operator  '/'/2
   called as sites / 'test.html'
Run Code Online (Sandbox Code Playgroud)

如何在Erlang中跨目录复制文件?

非常感谢,

LRP

Isa*_*sac 14

问题是sites/test.html有特殊字符,必须在单引号内.尝试:

file:copy(test.html, 'sites/test.html').
Run Code Online (Sandbox Code Playgroud)

或者您可以使用字符串:

file:copy("test.html", "sites/test.html").
Run Code Online (Sandbox Code Playgroud)