Copy link to clipboard
Copied
Hello,
I am wondering how to delete a folder (with files in it, if possible) via the window.cep.fs object?
Using deleteFile gives the error "8" ERR_NOT_FILE, and if I try deleteFileOrDirectory(), it says that's not a function.
Copy link to clipboard
Copied
This is for NodeJS but the ideas the same
node.js - Remove directory which is not empty - Stack Overflow
var fs = require('fs');
var deleteFolderRecursive = function(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file, index){
var curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
Copy link to clipboard
Copied
Thanks Trevor, I've got about the same achieved through old-school jsx-based deletion for the current need. However the documentation keeps saying that 'deleteFileOrDirectory' should be working - are you saying that there's actually no possibility with the current (CEP9) window.cep.fs object?
I'm also sure I updated by CSInterface.js to the 9.2.0 version.
Copy link to clipboard
Copied
No, I've done it using the node fs method and not the window.cep.fs object so I don't know about any changes.
Copy link to clipboard
Copied
In my case, it was a folder which could not be deleted by "deleteFile()", returning only {err: 8}.
I thought it was because of a space in the folder name, but from cep.fs we see that error 8 means "not a file"...
So I need to switch to node fs, because cep.fs does not support deleting folders?!
Copy link to clipboard
Copied
Edit: @T@Trevor: 's answer is correct 🙂
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more