• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

CFileDialog and OFN_SHAREAWARE => asserttion error


I want to use the CFileDialog so that a user can choose a file. The file will not be opened now, but rather stored in my inifile. The problem is that I can get a share violation when choosing the file, so I found OFN_SHAREAWARE, which I thought should ignore the error and just return the filename, which is exactly what I want, but when doing DoModal() I get assertion error in MS code.

My code:

CFileDialog cfd( true, "tok\0", initialFilename );
cfd.m_ofn.Flags = OFN_SHAREAWARE;
if( cfd.DoModal() == IDOK )
   m_filename = cfd.GetPathName( );
   UpdateData( false );

How can I solve this one??
1 Solution
You should use a bitwise-OR operator in your changes of m_ofn.Flags to keep the default behavior intact.

cfd.m_ofn.Flags |= OFN_SHAREAWARE;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now