0

我得到open failed: EISDIR (Is a directory)。我从中找到的所有解决方案都说 call file.getParentFile().mkdirs(),但我仍然收到该错误。它打印出来,Good但也打印出来Directory not created

    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state))
    {
        Log.e("test", "Good");
    }

    File f = Environment.getExternalStorageDirectory();
    lvlWriter.writeLevel(f);

.

writeLevel(File f)
{
        File file = new File(f, "1.txt");

        if (!file.getParentFile().mkdirs())
        {
            Log.e("test", "Directory not created");
        }

        if (!file.exists())
        {
            file.createNewFile();
        }
4

1 回答 1

2

好的,我找到了答案。我可能试图写入 Bluestacks 中不存在的文件夹。这是有效的:

String base = Environment.getExternalStorageDirectory().getAbsolutePath() + "/bstfolder/BstSharedFolder/";

然后可以在 Windows 中访问该文件夹C:\ProgramData\BlueStacks\UserData\SharedFolder

于 2014-07-01T17:22:48.433 回答