"encountered a sharing violation while accessing" error message

권영 김 0 Reputation points
2023-04-06T01:03:32.39+00:00
CStdioFile file;

if(!file.Open(strPath, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite, &exception))

{

	    CString msg;

            static const int MSG_SIZE = 1024;

            TCHAR* p = msg.GetBuffer(MSG_SIZE);

            exception.GetErrorMessage(p, MSG_SIZE);

            msg.ReleaseBuffer(-1);

            AfxMessageBox(msg);

	    return;

}

=================================================================

Intermittent file creation error occurs
The result of checking the error message using the above code

"encountered a sharing violation while accessing" checked error message.

The file was never accessed while it was being created, and as mentioned, it happens intermittently.

Runs on Win10, implemented using VS2010

Please tell me how to solve this problem.
Developer technologies | C++
Developer technologies | Visual Studio | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.