Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

"Permission Denied" error when reading a file

katmankatman Member Posts: 24
I'm looking for troubleshooting suggestions. I'm getting a "Permission Denied" error (from strerror) when reading a text file after opening an output file. But this is only on the second time through my routine.

Details:

Microsoft Visual C++ mfc application.

My routine reads a text file (call it the Command text file) consisting of one letter commands each followed by a path/filename. So each line of the Command text file is of the form x,c:pathfilename where x is the command. There are 3 commands: 1) open and load setup values, 2) open an output file for use by other routines, 3) open an input file for use by other routines.

I have several Command text files. The first time through the routine, all commands execute without errors regardless of which Command text file I read. I then operate on the open input and output files in other routines and close them. When that processing is finished, I re-enter the routine to process a new Command text file. On the second pass, I get the "Permission Denied" error on the next attempt to read a new Command text file after processing command 2 to open the output file. So I cannot read the rest of the second Command text file after that. The same Command text file reads without errors if I access it on the first pass.

I've narrowed the error culprit down to right after the step of opening the output file, but I cannot figure out why this error is happening. Obviously I'm missing something. Any suggestions or observations or troubleshooting tips would be appreciated.



Sign In or Register to comment.