This language bar is your friend. Select your favorite languages!

Idiom #144 Check if file exists

Set boolean b to true if file at path fp exists on filesystem; false otherwise.

$b = file_exists($fp);
import std.file;
bool b = fp.exists;
import "os"
_, err := os.Stat(fp)
b := !os.IsNotExist(err)
uses sysutils;
b := FileExists(fp);
import os
b = os.path.exists(fp)
b = File.exist?(fp)
let _b = std::path::Path::new(_fp).exists();

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Related idioms