Prevent Windows from opening a dialog to check read permissions

I use MFC CFileDialog to select a file. I'm interested in the full path to the file, since my application is not going to open it directly. Although it is forbidden to select a file in the file dialog box, stating: "You do not have read permission to open this file." (Which is right - I do not have permission to read, I do not want to open the file.)

So, is there a way under Windows to navigate to the path using the file dialog box?

Here is my code:

CFileDialog dlg(true, nullptr, nullptr, OFN_FILEMUSTEXIST, nullptr, nullptr, 0, true);
dlg.DoModal();
+4
source share
2 answers

I found a workaround by (ab) using a file save dialog that does not check if you have read / write permissions to the file:

CFileDialog dlg(false, nullptr, nullptr, OFN_FILEMUSTEXIST, nullptr, nullptr, 0, true)

, :

dlg.m_ofn.lpstrTitle = "Select file";

+1

OFN_FILEMUSTEXIST, .

, .

, OFN_FILEMUSTEXIST , ( , ).

0

Source: https://habr.com/ru/post/1599023/


All Articles