I'm creating a program that maintains a log file. The file is created at the start up of the program and appended to throughout the run. This works perfectly fine, but I went and manually added the program to run at start up in the registry. The program runs as normal, but the file isn't created. using fstream::is_open() says that the file is opened and attached to the stream, but the file itself does not exist.

Now, the obvious solution is to just open the file later, some time after start up, and keep the data in memory until needed, but I am more curious as to why the file isn't created and if there is any way to allow for this other than creating a buffer and creating the file later.

Does this occure only when the program is launched at startup? Under what operating system?
I had a similar problem under windows and figured it was because the program wasn't given permission to save files.

Does this occure only when the program is launched at startup? Under what operating system?
I had a similar problem under windows and figured it was because the program wasn't given permission to save files.

Only at startup, if I open the program manually the file is created fine, and I'm running Windows XP

In case anyone else every has this problem, a friend sorted me out and told me the problem lies in the fact that I was using relative paths as opposed to absolutes. Using GetModuleFileName() to find the absolute path solved this problem.

Good that you have the project working but with xp the rel file path should be possible.
I though I'd mention this just in case you are having a problem that I encountered:

Are you using Norton Antivirus if so make sure that you disable their automatic recycle bin. It can break the MFT in a way that is only apparent to people who use fstream and could cause your problem

Only at startup, if I open the program manually the file is created fine, and I'm running Windows XP

In case anyone else every has this problem, a friend sorted me out and told me the problem lies in the fact that I was using relative paths as opposed to absolutes. Using GetModuleFileName() to find the absolute path solved this problem.

Edited 6 Years Ago by tetron: n/a

This question has already been answered. Start a new discussion instead.