createNewFile() error open failed: ENOENT (No such file or directory) solution

I encountered an error of open failed: ENOENT (No such file or directory) using createNewFile() in writing Android applications. I checked many methods on the Internet, but none of them could solve my problem. Finally, I found the problem, so I wrote a summary.

First, summarize the common solutions on the Internet:

1. The problem of hierarchical directory https://blog.csdn.net/zhouyingge1104/article/details/49612319

mkdir() did not work, mkdirs() should be used;

2. Permission issues http://www.cnblogs.com/zzw1994/p/5021118.html

Above API 23+, not only need to add permissions in AndroidManifest.xml, but also request permissions in JAVA code.

 

The above are the common solutions on the Internet, and my problem is:

3. File naming problem

Through createNewFile(), the naming convention should also be followed. If it contains illegal symbols, an error of open failed: ENOENT (No such file or directory) will also be reported.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326153568&siteId=291194637