Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.