Hello. I've been working on an application that reads and writes to a data file. I have everything working fine except that when other computers try to use it, they can not find the file. How can I change my program to read the file in the same folder as it regardless of the computer it's on. In case it matters, all the computers in question are Windows operated. Thank you in advance.
It will look in the current working directory, which is not necessarily the same as where the exe is.
If he runs it off the .exe then it'll be the directory of the exe. Only time it wont be the same directory (that I'm aware of) is when you're running the code, in which case it'll be the directory of the .cpp file. I assumed he is running off an .exe since that's the easiest way to move around an application.
you may be able to call the subst command via system to map the remote target to a common location eg z:\ and get it that way. Do you have the remote folder shared? The first step, really, is to access the file yourself via windows explorer to prove that your network and sharing are set up right. From there, share it one way or another and you can open it.
If he runs it off the .exe then it'll be the directory of the exe.
No it'll be in the current working directory. If you run a program from the command line, that's whatever directory you're in when you run it. If you run it by clicking on an icon, it's whatever directory the shortcut has in the "Start In" field.
The bottom line is that the current working directory and the location of the exe are independent of each other.
I wonder where the working directory will be when you run it off the .exe directly... could it be the same place the .exe is? He's on Windows, why would he be opening it from a command line? And the part about the shortcut is false. It would still be in the directory of the original .exe - that's where the shortcut leads.
EDIT: Misread what you said about the shortcut, but it doesn't contradict what I said. The "start in" directory is automatically the directory of the .exe . Sure, working directory and .exe location can be different, but you'd have to go out of your way to make it so. I doubt the OP is trying that hard to get in his own way.