File.mkdir or mkdirs return false - Reason?

前端 未结 4 1290
我寻月下人不归
我寻月下人不归 2020-12-09 07:33

Why file.mkdir is returning false?

Google indicates that there could be several reasons (e.g. security, permissions, pathname, etc).

My questions:

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 07:57

    Here's something specific to Windows: In my case, the file.mkdir() method was failing with NoSuchFileException because I was trying to create a nested directory structure directly (e.g. results\results_ddMMyyyy without first creating the results directory) on Windows.

    However, the exact same code worked fine on my Mac, i.e. no such exception was thrown on Mac and the intermediate results directory was created implicitly by the file.mkdir() method.

    Hope this helps someone in future.

提交回复
热议问题