fileExists Function doesn't work

Hi and Welcome it's my first post :)

I'm traing to write a function to check if a file exists, and evertything seams to be good, no errors etc. but the problem is that the function always returns false, and i don't know why. I'll be apprieciated for any help

bool ifFileExists(std::string File)
{
ifstream ifs((char*)&File);
if(ifs.is_open()){
return true;
}
return false;
}

Ps. I'm using visual studio 2008
Last edited on
Perhaps try:

1
2
3
4
5
6
7
8
bool ifFileExists(std::string File)
{
ifstream ifs(File.c_str());
if(ifs.is_open()){
return true;
}
return false;
}


And welcome :)
Thanks, it works :)
Topic archived. No new replies allowed.