当文件路径很长时,为什么CFileDialog :: GetNextPathName不起作用? [英] Why CFileDialog::GetNextPathName doesn't work when the file path is long?

查看:209
本文介绍了当文件路径很长时,为什么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.lpstrFilem_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不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆