The method for verifying the existence of a file or folder using Deno is existsSync
.
Here is an example code:
import { existsSync } from "deno";
if (existsSync("/path/to/file.txt")) {
console.log("File exists.");
} else {
console.log("File does not exist.");
}
if (existsSync("/path/to/folder")) {
console.log("Folder exists.");
} else {
console.log("Folder does not exist.");
}
Note that existsSync
returns a boolean value indicating whether the file or folder exists or not.
Asked: 2023-05-07 15:14:03 +0000
Seen: 11 times
Last updated: May 07 '23