hi guys ... i wonder how is it possible to save a file in current directory .. ?!!!
i mean i wanna save files in a current directory as the exe files running
is that clear enough or i should explain a bit more?
tanx in advance
hi guys ... i wonder how is it possible to save a file in current directory .. ?!!!
i mean i wanna save files in a current directory as the exe files running
is that clear enough or i should explain a bit more?
tanx in advance
Do you mean "in the current directory" as defined by "GetCurrentDirectory()" or similar would give you back? If so, just open a file for writing without specifying a directory, and it will be where you are at the moment.
If on the other hand you require the directory from which the application was started, it's a bit harder - if this is what you want, search the forum.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
hi mat ..
see i mean , when sb runs my program somewhere , if there is any need to save the stuff thats been calculated using my prog , it saves where the program started ,,,
for example the program is located on the desktop .. and when you run it and now you wana save sth ,it saves on the desktop ..
is that clear?
by the way im a noob to Win APIs please tell me how i can Master the APIs and learn them great
tanx in advance
I'm quite sure there's an easy answer, but I don't know it. I'm quite sure someone else will come forward, but why don't you try searching the forum first - I'm sure that you can find it if you search for "save data same directory application" or some such.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
If another directory is active rather than the one the app lies in, you can get it using GetModuleFileName or something, I believe.
It returns the full directory (including filename) to your EXE. Then switch to that directory and save using typical file-saving functions such as fopen/fwrite/fclose.
first of all tanx Mat .. i ll do searching before i post ...
and
well i know this .. i can ask the user to enter a path(sth like this scanf("%s",Path);and the fp=fopen(Path,"w"); and then save the stuff .. but i dont want any hassle...
all i want is you find a way to save it in a directory where its running
( i wonder how some guys do it ...)
and
Ok let me try this and tell you what happensIf another directory is active rather than the one the app lies in, you can get it using GetModuleFileName or something, I believe.
It returns the full directory (including filename) to your EXE. Then switch to that directory and save using typical file-saving functions such as fopen/fwrite/fclose.
tanx guys
Last edited by Masterx; 11-17-2007 at 09:05 PM.
or to find the current directory use pwd command to get the current working directory and start saving the file in there.
ssharish