MFC 相当于 Java File#isDirectory()
MFC 中是否有与 Java 文件方法 isDirectory() 等效的方法? 我尝试使用这个:
static bool isDirectory(CString &path) {
return GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY;
}
但它似乎不起作用。
Is there an equivalent to the Java File method isDirectory() in MFC? I tried using this :
static bool isDirectory(CString &path) {
return GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY;
}
but it doesn't seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
CFileFind::IsDirectory()
http://msdn.microsoft .com/en-us/library/scx99850(VS.80).aspx
编辑:
如果将文件名更改为具有通配符,则可以执行 a
来获取所有匹配的文件。
CFileFind::IsDirectory()
http://msdn.microsoft.com/en-us/library/scx99850(VS.80).aspx
EDIT:
If you change filename to have wildcards, you can do a
to get all matching files.
很抱歉问题的答案可能“不一致”,但也许你会发现它很有用,因为每当我在 Windows 中需要类似的东西时,我不使用 MFC,而是使用常规的 Windows API:
Sorry for possibly "inconsistency" of answer to question but may be you'll see it useful because anytime I need something like this in Windows I am NOT using MFC but regular Windows API:
根据要求MFC解决方案:
a_FSItem 要测试的项目的路径(检查 CFile::GetStatus() 是否满足所需要求)。
如果您希望包含卷根作为有效目录,只需将其添加到测试中
MFC solution as requested:
a_FSItem path ot the item to test (examine the CFile::GetStatus() for the needed requirements).
if you wish to include a volume root as a valid directory just add it to the test
它不是MFC,但我用的是这个:
Its not MFC, but I use this: