1. 程式人生 > >Android 5.1 建立多級資料夾失敗之奇怪的問題

Android 5.1 建立多級資料夾失敗之奇怪的問題

問題: Android 5.1 建立多級資料夾失敗之奇怪的問題
原始碼:
/**
 * 判斷資料夾是否建立
 */
private static String foundFolder(String... str){
    int length = str.length;
    String path = str[0] + "/";
    File file = new File(path);
    for (int i =1; i < length; i++){
        path = path + str[i] + "/";
        file = new File(path);
        if(!file.exists()){
            boolean b = file.mkdir();
            if(b){
                KLog.i("建立資料夾成功 = " + file.getPath());
            }else {
                KLog.i("建立資料夾失敗 = " + file.getPath());
            }
        }else {
            KLog.i("資料夾已存在 = " + file.getPath());
        }
    }
    return file.getPath();
}

奇因: 建立 /Mdeia/Video   建立這個目錄總是建立失敗。若是將Video 中的V 改成小寫v  就建立成功。不知什麼原因