can't open file to write, permission denied

  • Thread starter Thread starter lfvoydfv
  • Start date Start date
L

lfvoydfv

Guest
I have an MFC multidoc app. The release version isn't working quite right so I added some write statements to a FILE*. However, when I try to open the file using fopen_s, I get a "permission denied" error. Here's the code:


FILE * tmpfile;

errno_t err = fopen_s(&tmpfile, "debug.out", "wt");






if((int)err > 0)


{





char* errstr = strerror((int)err);






}



If I put this code in InitInstance, it works OK. If I put the code anywhere else, I get the "permission denied" error. I copied these lines of code to other multidoc apps, put it anywhere in those apps, and it works fine. For some reason this code gives the error in that one app. Any insight is greatly appreciated.




Continue reading...
 
Back
Top