Can't read data from file

Hi I really need your help.

I'm trying to read the data from a file and display it on the screen. If run the program from Visual Studio it works. However if I try to run it from command line it doesn't work anymore and I get the error "Can't open file". I try puttinf the file also in the debug folder where the executable is but it still doesn't work.
How can I fix it?
Here is my code:
string s;
ifstream infile;
infile.open ("file.dat");
if (infile.is_open())
{ cout<<"Fisier deschis\n";
while(infile.good()) // To get you all the lines.
{
getline(infile,s); // Saves the line in STRING.
cout<<s<<endl; // Prints our STRING.
}
}
else {cout<<"Could not open file";}
infile.close();

Hope someone can help me
Topic archived. No new replies allowed.