2015-09-16 160 views
0

在新的chrome文件系统api中,如何重命名目录?chrome文件系统 - 重命名目录

目录本身上的moveTo()似乎不起作用,我不想迭代目录中的所有文件。

有没有简单的方法来重命名它? 谢谢!

回答

0

这对我有用,你可以提供一些关于你遇到什么样的错误的更多信息吗?

我们直接从条目中获取父项,并且只需在同一父项下使用新名称来放置该文件夹。

请注意,如果新名称与旧名称相同,则会出现无效修改错误,即使您更改了名称中的大写字母也是如此。

var test = function(entry, new_name){ 
    entry.getParent(function(parent){ 
     entry.moveTo(parent , new_name, function(new_node){ 
      console.log(new_node) 
      console.log("Succes creating the new node") //We were able to rename the node 
     }, function(error){ 
      console.error(error) 
      console.error("Something wrong when finding the parent") 
     }) 
    }, function(error){ 
     console.error(error) 
     console.error("Something wrong when finding the parent") 
    }) 
} 

test(entry, "For the watch")