Why CFileDialog::GetNextPathName doesn#39;t work when the file path is long?(为什么文件路径长时 CFileDialog::GetNextPathName 不起作用?)
问题描述
使用 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
成员以获取指向 CFileDialog
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/en-US/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 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么文件路径长时 CFileDialog::GetNextPathName 不起作用?


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 这个宏可以转换成函数吗? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09