Check that file exists: Difference between revisions

(→‎{{header|AutoHotkey}}: Cleanup and example added)
(→‎{{header|C}}: added C++)
Line 96:
return 0;
}</lang>
 
=={{header|C++}}==
{{libheader|boost}}
<lang cpp>
#include "boost/filesystem.hpp"
#include <string>
#include <iostream>
 
void testfile(std::string name)
{
boost::filesystem::path file(name);
if (exists(file))
{
if (is_directory(file))
std::cout << name << " is a directory.\n";
else
std::cout << name << " is a non-directory file.\n";
}
else
std::cout << name << " does not exist.\n";
}
 
int main()
{
testfile("input.txt");
testfile("docs");
testfile("/input.txt");
testfile("/docs");
}
</lang>
 
=={{header|C sharp|C#}}==
973

edits