I'm working with the newest version of Edge (Canary release 86.0.615.0) and I can get the new Native File System API showOpenFilePicker to let me access files but I can't find a reference to the directoryHandle functions including the removeEntry function if the user elects to remove the file. Am I missing a special flag? I have an Origin-Tracker code and I also have the experimental flag set for the Native File System API.
Asked
Active
Viewed 346 times
0

ᄂ ᄀ
- 5,669
- 6
- 43
- 57

George Smyly
- 5
- 2
-
You could refer to the [official doc](https://wicg.github.io/native-file-system/#api-filesystemdirectoryhandle-removeentry) about how to use `removeEntry()` method. There're [some steps](https://wicg.github.io/native-file-system/#dom-filesystemdirectoryhandle-removeentry) you must run when you use the method. I also find the [TypeScript types for the spec](https://github.com/WICG/native-file-system/issues/151) and it also includes `FileSystemDirectoryHandle` interface which I think may be helpful. – Yu Zhou Aug 25 '20 at 07:30
1 Answers
0
If you have a directory handle, you can delete files or folders as in the example below:
// Delete a file.
await directoryHandle.removeEntry('Abandoned Projects.txt');
// Recursively delete a folder.
await directoryHandle.removeEntry('Old Stuff', { recursive: true });
You can obtain a directory handle from the picker:
const directoryHandle = await window.showDirectoryPicker();
To iterate over the entries of a directory, you can use the code snippet below:
for await (const entry of directoryHandle.values()) {
console.log(entry.kind, entry.name);
}

DenverCoder9
- 2,024
- 11
- 32