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++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01