javascript - 如何使用 javascript 文件系统 api 重命名目录?

标签 javascript html filesystems

如何使用 JavaScript 文件系统 API 重命名目录?

我试过如下:

dirNameWithPath = '/MyPictures3/New Folder';
newDirName = 'newTitle';
dirPath = '/MyPictures3';

filesystem.root.getDirectory(dirNameWithPath, {}, function(dirEntry) {
    dirEntry.moveTo(dirPath, newDirName, callback, errorHandler);
}); 

我收到以下错误:

FileError.INVALID_MODIFICATION_ERR

最佳答案

moveTo的第一个参数必须是 DirectoryEntry(不是字符串):

void moveTo(DirectoryEntry parent,
            optional DOMString newName,
            optional EntryCallback successCallback,
            optional ErrorCallback errorCallback);

parent 参数是“条目要移动到的目录”

"entry" 是要移动/重命名的目录 (directory.moveTo(newLocation, newName))。

关于javascript - 如何使用 javascript 文件系统 api 重命名目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14108653/

相关文章:

jquery - 表单标签中的数据属性

java - 在 Windows 上写入名称无效的文件时出现意外行为

Python 和 GetVolumeInformationW 和 GetDriveTypeW : list all disks and get disk info and filesystem flags

c - 在 C 中使用 ioctl() 设置不可变标志

javascript - 无限滚动在 React 中无法正常工作

javascript - 对 Google map 上的地理位置进行地理编码会出现错误

javascript - 我如何访问我发送到服务器文件的对象

javascript - 如何使用Google Identity Services JS SDK进行授权?

html - RTL 文本方向区域中奇怪的括号布局

jquery - 使用 CSS 在背景中定位移动的 <div> 元素