在blackberry应用程序的create directory上抛出"FileIOException:Not a directory"

Sur*_*rai 3 file-io blackberry create-directory

我想创建我的Application目录来保存我的配置文件.但黑莓模拟器在创建目录时抛出异常.我试过以下代码.

try {
FileConnection myAppDir = (FileConnection) Connector.open("file:///store/home/user/myAppDir", Connector.READ_WRITE);
    if (!myAppDir.exists()){
        myAppDir.mkdir(); // Exception throw here
    }
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

抛出异常

net.rim.device.api.io.file.FileIOException: Not a directory
Run Code Online (Sandbox Code Playgroud)

Chr*_*ler 5

您是否尝试在路径末尾添加正斜杠,以便连接器知道它是一个目录?

try {
FileConnection myAppDir = (FileConnection) Connector.open("file:///store/home/user/myAppDir/", Connector.READ_WRITE);
    if (!myAppDir.exists()){
        myAppDir.mkdir(); // Exception throw here
    }
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)