Debugger problem

Hey everyone,

I am having trouble with visual studio and running without debugging. I am trying to open a file that the user specifies. They input the file name and my function is just suppose to open it or report an error in opening. When I run the program using debugger it works fine, but if I try to run it without debugging the file wont open. If anyone could tell me if they know of a solution please let me know. I have already copied the txt file that I am trying to open to all the folders used by the project, just incase it couldn't find it for some reason. Thanks a lot! Here is my code for the function:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include "ioutil.h"
#include "towers.h"
#include <cstring>
#include <stdlib.h>

bool openFile(ifstream& ins)
{
string boardName;

cout << "Enter board filename: ";
cin >> boardName;
cout << endl;

ins.open(boardName.c_str());

if(ins.fail())
{
ins.clear();
clearInput();
cout << "Error opening file" << endl << endl;
return false;
}

return true;
}
When you run the program from the debugger, the current directory is the project directory.

When you run the program from explorer, the current directory is the exe directory.

Make sure your text file is in the same folder as the exe.
Topic archived. No new replies allowed.