Search code examples
javaandroidbluestacks

Android, Bluestacks: "open failed: EISDIR (Is a directory)"


I'm getting open failed: EISDIR (Is a directory). All the solutions I've found from that say to call file.getParentFile().mkdirs(), but I'm still getting that error. It prints out Good but also prints out 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();
        }

Solution

  • Okay, I found the answer. I was probably trying to write to a folder that doesn't exist in Bluestacks. This is what does work:

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

    And that folder can then be accessed in Windows from C:\ProgramData\BlueStacks\UserData\SharedFolder