The resolve()
method of the FileSystemDirectoryHandle
interface returns an Array
of directory names from the parent handle to the specified child entry, with the name of the child entry as the last array item.
resolve(possibleDescendant)
A Promise
which resolves with an Array
of strings, or null
if possibleDescendant
is not a descendant of this FileSystemDirectoryHandle
.
No exceptions are thrown.
The following asynchronous function uses resolve()
to find the path to a chosen file, relative to a specified directory handle.
async function returnPathDirectories(directoryHandle) {
const [handle] = await self.showOpenFilePicker();
if (!handle) {
return;
}
const relativePaths = await directoryHandle.resolve(handle);
if (relativePaths === null) {
} else {
for (const name of relativePaths) {
console.log(name);
}
}
}