我是靠谱客的博主 细心世界,这篇文章主要介绍c 语言判断文件夹,VC判断一个文件为目录的方法,现在分享给大家,希望可以做个参考。

本文实例讲述了VC判断一个文件为目录的方法,分享给大家供大家参考。具体实现方法如下:

这是一个自定义函数,用于判断一个文件是否为目录:

/**

* check whether a file is a directory

@return true if is a directory, else false(if file not exists, false)

*/

__declspec(dllexport) bool IsDirectory(const char* filename)

{

DWORD dwAttr = ::GetFileAttributes(filename);  //得到文件属性

if (dwAttr == 0xFFFFFFFF)    // 文件或目录不存在

return false;

else if (dwAttr&FILE_ATTRIBUTE_DIRECTORY)  // 如果是目录

return true;

else

return false;

}

以下是GetFileAttribute定义,摘自msdn:

Retrieves a set of FAT file system attributes for a specified file or directory.得到FAT文件系统的文件属性

Parameters

lpFileName

The name of the file or directory.In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend

最后

以上就是细心世界最近收集整理的关于c 语言判断文件夹,VC判断一个文件为目录的方法的全部内容,更多相关c内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(134)

评论列表共有 0 条评论

立即
投稿
返回
顶部