# VBForums CodeBank > CodeBank - C++ >  Check if directory exists - c++

## silentthread

Probably the most painfull part about getting this together was the fact that my compiler did not understand INVALID_FILE_ATTRIBUTES, so I had to do a cast thingy and check for ((DWORD)-1).

Also, I did not remember that c++ is sensitive to backslashes, so...
c:\test
should really be
c:\\test

Enjoy.....

Prototype....


```
bool FolderExists(string file);//function prototype
```

A sample call....


```
bool folderexist;
folderexist=FolderExists("c:\\test2");
cout << folderexist;
```

Function definition....


```
bool FolderExists(string file)
{
DWORD returnvalue;
returnvalue = GetFileAttributes(file.c_str());
	if(returnvalue == ((DWORD)-1))
	{
		return false;
	}
	else
	{	return true;
	}
}
```

----------

