Unable to open a file
-
Hi, I have created a MDI using MFC Application. The application is developed to process some input files and create an output file. At the end of the process, after the output file is created, iam trying to open the same. But its popping an error message saying "A sharing violation occured while accessing C:\temp\output.txt" And, iam not able to open it through any other application and the popping error message is "The document C:\temp\output.txt is being used by another application and cannot be accessed". I have properly coded on file opening and file closing. But still, iam not able to understand on why the problem occurs. Only, when i close my MFC application, iam able to access the created output file through any applicaton. Could someone, please help me, to get out of this situation. I thank in advance. Thanx Mughi Mughilan
-
Hi, I have created a MDI using MFC Application. The application is developed to process some input files and create an output file. At the end of the process, after the output file is created, iam trying to open the same. But its popping an error message saying "A sharing violation occured while accessing C:\temp\output.txt" And, iam not able to open it through any other application and the popping error message is "The document C:\temp\output.txt is being used by another application and cannot be accessed". I have properly coded on file opening and file closing. But still, iam not able to understand on why the problem occurs. Only, when i close my MFC application, iam able to access the created output file through any applicaton. Could someone, please help me, to get out of this situation. I thank in advance. Thanx Mughi Mughilan
-
What`s your code at your file closing. I think that`s where the problem is.
Work hard and a bit of luck is the key to success.
:)
Hi, Here is the code. FILE *fp = fopen(this->output,"w"); fprintf(fp,"8\n"); for(rc=0;rc<9;rc++) for(gc=0;gc<9;gc++) for(bc=0;bc<9;bc++) { lut[0][rc][gc][bc] = (lut[0][rc][gc][bc]>255)?255:lut[0][rc][gc][bc]; lut[1][rc][gc][bc] = (lut[1][rc][gc][bc]>255)?255:lut[1][rc][gc][bc]; lut[2][rc][gc][bc] = (lut[2][rc][gc][bc]>255)?255:lut[2][rc][gc][bc]; fprintf(fp,"%d %d %d\n",lut[0][rc][gc][bc],lut[1][rc][gc][bc],lut[2][rc][gc][bc]); } fclose(fp); When my MFC application still runs, Iam able to open the file in dos prompt, but not in any of WIN32 application or in my own MFC application. Am still not getting it. Could you please help me out, if you have the answers. Thanx Mughi
-
Hi, Here is the code. FILE *fp = fopen(this->output,"w"); fprintf(fp,"8\n"); for(rc=0;rc<9;rc++) for(gc=0;gc<9;gc++) for(bc=0;bc<9;bc++) { lut[0][rc][gc][bc] = (lut[0][rc][gc][bc]>255)?255:lut[0][rc][gc][bc]; lut[1][rc][gc][bc] = (lut[1][rc][gc][bc]>255)?255:lut[1][rc][gc][bc]; lut[2][rc][gc][bc] = (lut[2][rc][gc][bc]>255)?255:lut[2][rc][gc][bc]; fprintf(fp,"%d %d %d\n",lut[0][rc][gc][bc],lut[1][rc][gc][bc],lut[2][rc][gc][bc]); } fclose(fp); When my MFC application still runs, Iam able to open the file in dos prompt, but not in any of WIN32 application or in my own MFC application. Am still not getting it. Could you please help me out, if you have the answers. Thanx Mughi
Hi, The file was opened somewhere else (for other module) and was not closed. I had to track down the whole flow of the application and had the problem solved. Thats been a silly mistake and sorry for the inconvenience caused. Thanks for your support. Thanx Mughi
-
Hi, I have created a MDI using MFC Application. The application is developed to process some input files and create an output file. At the end of the process, after the output file is created, iam trying to open the same. But its popping an error message saying "A sharing violation occured while accessing C:\temp\output.txt" And, iam not able to open it through any other application and the popping error message is "The document C:\temp\output.txt is being used by another application and cannot be accessed". I have properly coded on file opening and file closing. But still, iam not able to understand on why the problem occurs. Only, when i close my MFC application, iam able to access the created output file through any applicaton. Could someone, please help me, to get out of this situation. I thank in advance. Thanx Mughi Mughilan