Hey,

I am writing a program that reads in text files that were generated from another program. Some of the files are able to open with no problem but others will not open unless I rename them.

For example:
4_UncommonHints_10-07-2008_Ideas.txt opens fine

but

5_CommonHints_10-30-2008_Ideas.txt will NOT open unless I rename it. Even if I hardcode the filename into the program, it cannot be opened. If I rename it to test.txt the ifstream opens it with no problems.

Is there any reason this would be happening? I would really like to be able to keep the filenames if I can.

Thanks,

Matt

That is an odd one.

What I would do is try opening files the same name but with one character changed.
To see where the problem lies, and if something needs escaping.

That is of course, if it's the filename that is the problem and not the file itself.

That is an odd one.

What I would do is try opening files the same name but with one character changed.
To see where the problem lies, and if something needs escaping.

That is of course, if it's the filename that is the problem and not the file itself.

Yeah, it was the filenames. While I was looking through the folder for the 1000th time, I tried sorting the files by name and noticed some were out of place. Apparently some files had spaces in front of the name that weren't being read into the program so it was trying to open "name.txt" not " name.txt." I went through and removed the spaces from the problem files and it works now.

Thanks!
matt

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