var fs = require('fs');
if (!fs.existsSync(newDest)) fs.mkdirSync(newDest,'0777', true);
const fs = require("fs")
fs.access("./directory-name", function(error) {
if (error) {
console.log("Directory does not exist.")
} else {
console.log("Directory exists.")
}
})
//check directory exist
string directoryExistPath = @"C:UsersYogeshkumar HadiyaDesktopDirectoryHandling";
if (Directory.Exists(directoryExistPath))
{
Console.WriteLine("Directory exist");
}
else
{
Console.WriteLine("Directory not exist");
}
>>> import os
>>> os.path.isdir('new_folder')
True
>>> os.path.exists(os.path.join(os.getcwd(), 'new_folder', 'file.txt'))
False