View source code
Display the source code in std/file.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.file.exists
Determine whether the given file (or directory) exists.
bool exists(R)
(
R name
)
if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R);
bool exists(R)
(
auto ref R name
)
if (isConvertibleToString!R);
Parameters
Name | Description |
---|---|
name | string or range of characters representing the file name |
Returns
true if the file name specified as input exists
Example
auto f = deleteme ~ "does.not.exist";
assert(!f .exists);
f .write("hello");
assert(f .exists);
f .remove;
assert(!f .exists);
Example
assert("." .exists);
assert(!"this file does not exist" .exists);
deleteme .write("a\n");
scope(exit) deleteme .remove;
assert(deleteme .exists);
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.