deafault file write location

Hi there.

I am writing a C program and I want to have the program write a ReadMe file with the instructions for the program on it. I want this file to be written to the same location that the user keeps the exe.Is this possible, or do I need to have the user enter the location?

I know it is possible to default to the project folder, this is not what I want because the user will not have a project folder. If this is not possible I am open to any suggestions on how to make a ReadMe file for a user of my program.

I greatly appreciate any help. I have not been able to find the answer anywhere.

Thanks,
-Adrian
Last edited on
The README file is usually distributed with the program, not created by it. In fact, having the program create it is a rather bad idea. The user will expect a README file to be included with the program, and will perceive its absence as a lack of documentation. They will never expect the program to write one to the directory where the .exe is, and many will be annoyed or angered by the program writing to their disk unexpectedly.

If you insist on dumping files to the user's disk, the Windows GetModuleFileName function will tell you what you need to know:
http://msdn.microsoft.com/en-us/library/ms683197%28v=vs.85%29.aspx
Thank you for both your advice on program etiquette, and the link.

So If I don't force a README on the user, is it still ok to rely completely on the README to instruct the user on how to use the program?

Also, my program has a save function to write the current string to a text file, would it also be wrong to automatically put that with the exe when the user hits the save button? I know I can have the user set the file location, but that involved them typing a long path with no mistakes, and I'm not even sure the average users I am making this for would understand the prompt.

Any suggestions?
If this is a console application, most likely average users don't know what this is and they will not use it.
Anyway, use GetSaveFileName() API to display a "save as" dialog for the user.


As for the readme thing, use something like GetTempPath() to write readme file here, not the same location as the exe if you want and DeleteFile() when exit.
Topic archived. No new replies allowed.