Ask Your Question
3

What is the method for verifying the existence of a file or folder using Deno?

asked 2023-05-07 15:14:03 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-05-07 15:19:01 +0000

woof gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-07 15:14:03 +0000

Seen: 11 times

Last updated: May 07 '23