PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How do i look for a file in the current dir?

Hello, Im using fscanf() for file reading, but how do i get fopen() to look in the current directory for the file im loading? On my pocket pc it imediatly looks for the base dir. I tried typing in the whole path, but i suspect that a path with spaces in it messes the program up. I hope someone has run into this problem before......
There is no concept of "execution directory" in PocketPCs. What you have to do is actually obtain the path of your executable and use it to open your file.

To obtain the executable's pathname, use:

Code:

...
TCHAR pathname[MAX_PATH];

GetModuleFileName( 0, pathname, MAX_PATH );
...


You then need to stripoff the executable's filename from "pathname" and replace it with the name of the file you want to open. You do this by searching for the last occurence of the '\' character (or is it '/'?)
Paths can contain spaces. Just make sure you specify a slash at the beginning: "\My Documents\Something.psw".

Dan East