Jack
2009-12-04 11:11:50 UTC
Hi gurus,
I am trying hard on this, but with success.
I'd like to get the relative path \\data\\Demo.dat
void OpenFile (char *filename)
{
char szPath[256];
GetCurrentDirectoryA(sizeof(szPath), szPath);
SetCurrentDirectoryA(szPath);
strcat (szPath, filename);
FILE *fp = fopen(szPath, "rb");
//////////////////////////////
When I put \\data\\Demo.dat there as the parameter.
The file being referenced is
C:\Current Path\Project\Project\data\
When I place \\..\\data\\Demo.dat there
it works but I don't like it that way
C:\current Path\Project\data
As I don't want to hard code it,
How can I make it always relative to the exe file....
Sorry as it has been asked for trillion times.
Thanks
Jack
I am trying hard on this, but with success.
I'd like to get the relative path \\data\\Demo.dat
void OpenFile (char *filename)
{
char szPath[256];
GetCurrentDirectoryA(sizeof(szPath), szPath);
SetCurrentDirectoryA(szPath);
strcat (szPath, filename);
FILE *fp = fopen(szPath, "rb");
//////////////////////////////
When I put \\data\\Demo.dat there as the parameter.
The file being referenced is
C:\Current Path\Project\Project\data\
When I place \\..\\data\\Demo.dat there
it works but I don't like it that way
C:\current Path\Project\data
As I don't want to hard code it,
How can I make it always relative to the exe file....
Sorry as it has been asked for trillion times.
Thanks
Jack