问题描述
使用CFileDialog
类,我选择了放置在具有长路径的目录中的多个文件.当我只选择一个或两个文件时可以.但是当我同时选择三个文件时,它仅返回第三文件路径的一部分. (看起来它可能限制为512个字符)如何解决此问题?
Using CFileDialog
class, I select multiple files placed in a directory with a long path. It's OK when I select only one or two files; but when I select three files at the same time it returns only a part of the third file path. (Looks like it's limited to 512 characters possibly) How can I resolve this?
推荐答案
MFC使用大小为_MAX_PATH
的默认缓冲区,这就是为什么您看到这种行为的原因.查看dlgfile.cpp
以了解CFileDialog::CFileDialog
的实现,您将看到m_ofn.lpstrFile
和m_ofn.nMaxFile
被设置.
MFC uses a default buffer of size _MAX_PATH
and that's why you are seeing that behavior. Look at dlgfile.cpp
for the implementation of CFileDialog::CFileDialog
and you will see m_ofn.lpstrFile
and m_ofn.nMaxFile
being set.
如果需要,可以指定更大的缓冲区.在调用DoModal
之前,您可以访问CFileDialog::m_pOFN
成员以获取指向OPENFILENAME
将要使用的OPENFILENAME
的指针并直接对其进行更新,或者调用CFileDialog::GetOFN
以获得对该结构的引用并对其进行更新.
You can specify a larger buffer if you want to. Before calling DoModal
you can either access the CFileDialog::m_pOFN
member to get a pointer to the OPENFILENAME
that the CFileDialog
will use and update it directly or call CFileDialog::GetOFN
to get a reference to the structure and update that.
无论哪种方式,您都将找到帮助: http ://msdn.microsoft.com/zh-CN/library/ms646839(v = vs.80).aspx
Either way you will find this helpful: http://msdn.microsoft.com/en-US/library/ms646839(v=vs.80).aspx
这篇关于当文件路径很长时,为什么CFileDialog :: GetNextPathName不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!