CFileFind Class
来源:互联网 发布:org.apache server 编辑:程序博客网 时间:2024/06/05 08:03
CFileFind:CObject
The MFC class CFileFind performs local file searches and is the base class forCGopherFileFind and CFtpFileFind, which perform Internet file searches.CFileFind includes member functions that begin a search, locate a file, and return the title, name, or path of the file. For Internet searches, the member functionGetFileURL returns the file’s URL.
CFileFind is the base class for two other MFC classes designed to search particular server types:CGopherFileFind works specifically with gopher servers, and CFtpFileFind works specifically with FTP servers. Together, these three classes provide a seamless mechanism for the client to find files, regardless of the server protocol, the file type, or location, on either a local machine or a remote server.
The following code will enumerate all the files in the current directory, printing the name of each file:
CFileFind finder; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); cout << (LPCTSTR) finder.GetFileName() << endl; }
To keep the example simple, this code uses the standard C++ library cout class. Thecout line could be replaced with a call to CListBox::AddString, for example, in a program with a graphical user interface.
For more information about how to use CFileFind and the other WinInet classes, see the articleInternet Programming with WinInet inVisual C++ Programmer's Guide.
#include <afx.h>
CFileFind Class Members
Construction
CFileFindConstructs a CFileFind object.Attributes
GetLengthGets the length of the found file, in bytes.GetFileNameGets the name, including the extension, of the found fileGetFilePathGets the whole path of the found file.GetFileTitleGets the title of the found file. The title does not include the extension.GetFileURLGets the URL, including the file path, of the found file.GetRootGets the root directory of the found file.GetCreationTimeGets the time the file was created.GetLastAccessTimeGets the time that the file was last accessed.GetLastWriteTimeGets the time the file was last changed and saved.MatchesMaskIndicates the desired file attributes of the file to be found.IsDotsDetermines if the name of the found file has the name "." or "..", indicating that is actually a directory.IsReadOnlyDetermines if the found file is read-only.IsDirectoryDetermines if the found file is a directory.IsCompressedDetermines if the found file is compressed.IsSystemDetermines if the found file is a system file.IsHiddenDetermines if the found file is hidden.IsTemporaryDetermines if the found file is temporary.IsNormalDetermines if the found file is normal (in other words, has no other attributes).IsArchivedDetermines if the found file is archived.Operations
CloseCloses the search request.FindFileSearches a directory for a specified file name.FindNextFileContinues a file search from a previous call to FindFile.例如查找并提取F:\VBA下文件名:
CString strPath = "F:\\VBA\\*.*";
CString strFileName;
CFileFind finder;
BOOL bWorking = finder.FindFile(strPath);
while (bWorking)
{
bWorking = finder.FindNextFile();
if(finder.IsDirectory()) //若确定找到的文件是否是一个目录,结束本次循环。
continue;
strFileName = finder.GetFileName();
cout << (LPCTSTR)strFileName << endl;
}
finder.Close();
- CFileFind Class
- CFileFind
- CFileFind
- CFileFind
- CFileFind
- 【MFC学习笔记3】ASSERT()函数用法,CFileFind Class 说明。
- CFileFind类
- CFileFind类
- CFileFind类
- CFileFind类
- CFileFind类
- CFileFind用法
- CFileFind例子
- CFileFind类
- CFileFind类
- CFileFind类
- CFileFind::FindFile
- CFileFind用法
- UESTC 1253 阿里巴巴和n个大盗 博弈、策略
- C语言--学习路径
- LightOJ 1214 Large Division
- Android studio 混编之JNI环境搭建
- VC6.0中友元函数无法访问类私有成员的解决办法
- CFileFind Class
- Swift学习笔记(1)
- Eclipse找不到zipalign tool,找不到hprof-conv.exe
- HDOJ 5499 SDOI
- Servlet 技术
- AES加密,128-192-256,方案一
- LINUX学习笔记(四)RAID LVM
- MySQL的安装、编译Qt驱动和测试
- 分布式process总结之一:Multicast,Membership,Election