有什么库函数可以访问Windows文件系统的?

sportboys 2004-12-30 03:31:41
比如说想知道一个目录下有哪些文件和子目录之类的
谢谢各位大侠了
...全文
127 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzheng318 2004-12-30
  • 打赏
  • 举报
回复
// This code fragment prints out a very verbose directory
// listing for all the files in the root directory on the
// C: drive. After the file's name, each attribute of the
// file is printed, as are the creation, last access, and
// last write times.

CFileFind finder;

BOOL bWorking = finder.FindFile(_T("C:\\*.*"));

while (bWorking)
{
bWorking = finder.FindNextFile();

_tprintf(_T("%s\n\t"), (LPCTSTR) finder.GetFileName());
_tprintf(_T("%c"), finder.IsArchived() ? 'A' : 'a');
_tprintf(_T("%c"), finder.IsCompressed() ? 'C' : 'c');
_tprintf(_T("%c"), finder.IsHidden() ? 'H' : 'h');
_tprintf(_T("%c"), finder.IsNormal() ? 'N' : 'n');
_tprintf(_T("%c"), finder.IsReadOnly() ? 'R' : 'r');
_tprintf(_T("%c"), finder.IsSystem() ? 'S' : 's');
_tprintf(_T("%c"), finder.IsTemporary() ? 'T' : 't');

_tprintf(_T("\t%I64u byte(s)\n"), finder.GetLength());

CTime tempTime;
CString str;

_tprintf(_T("\tCreated : "));
if (finder.GetCreationTime(tempTime))
{
str = tempTime.Format(_T("%c"));
_tprintf(_T("%s\n"), (LPCTSTR) str);
}
else
_tprintf(_T("(unavailable)\n"));

_tprintf(_T("\tLast Access: "));
if (finder.GetLastAccessTime(tempTime))
{
str = tempTime.Format(_T("%c"));
_tprintf(_T("%s\n"), (LPCTSTR) str);
}
else
_tprintf(_T("(unavailable)\n"));

_tprintf(_T("\tLast Write : "));
if (finder.GetLastWriteTime(tempTime))
{
str = tempTime.Format(_T("%c"));
_tprintf(_T("%s\n"), (LPCTSTR) str);
}
else
_tprintf(_T("(unavailable)\n"));

_tprintf(_T("\n"));
}

CMyMfc 2004-12-30
  • 打赏
  • 举报
回复
Function Description
AreFileApisANSI Determines whether the file I/O functions are using the ANSI or OEM character set code page.
CancelIo Cancels all pending I/O operations that were issued by the calling thread for the specified file handle.
CloseHandle Closes an open object handle.
CopyFile Copies an existing file to a new file.
CopyFileEx Copies an existing file to a new file.
CopyProgressRoutine An application-defined callback function used with CopyFileEx and MoveFileWithProgress.
CreateDirectory Creates a new directory.
CreateDirectoryEx Creates a new directory with the attributes of a specified template directory.
CreateFile Creates or opens a file object.
CreateIoCompletionPort Creates and I/O completion port or associates an instance of an opened file with a newly created or an existing I/O completion port.
DefineDosDevice Defines, redefines, or deletes MS-DOS device names.
DeleteFile Deletes an existing file.
FileIOCompletionRoutine An application-defined callback function used with ReadFileEx and WriteFileEx.
FindClose Closes the specified search handle.
FindCloseChangeNotification Stops change notification handle monitoring.
FindFirstChangeNotification Creates a change notification handle.
FindFirstFile Searches a directory for a file whose name matches the specified file name.
FindFirstFileEx Searches a directory for a file whose name and attributes match those specified.
FindNextChangeNotification Requests that the operating system signal a change notification handle the next time it detects an appropriate change.
FindNextFile Continues a file search.
FlushFileBuffers Clears the buffers for the specified file and causes all buffered data to be written to the file.
GetBinaryType Determines whether a file is executable.
GetCurrentDirectory Retrieves the current directory for the current process.
GetDiskFreeSpace Retrieves information about the specified disk, including the amount of free space on the disk.
GetDiskFreeSpaceEx Retrieves information about the specified disk, including the amount of free space on the disk.
GetDriveType Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
GetFileAttributes Retrieves attributes for a specified file or directory.
GetFileAttributesEx Retrieves attributes for a specified file or directory.
GetFileInformationByHandle Retrieves file information for a specified file.
GetFileSize Retrieves the size of a specified file.
GetFileSizeEx Retrieves the size of a specified file.
GetFileType Retrieves the file type of the specified file.
GetFullPathName Retrieves the full path and file name of a specified file.
GetLogicalDrives Returns a bitmask representing the currently available disk drives.
GetLogicalDriveStrings Fills a buffer with strings that specify valid drives in the system.
GetLongPathName Converts the specified path to its long form.
GetQueuedCompletionStatus Attempts to dequeue an I/O completion packet from a specified I/O completion port.
GetShortPathName Retrieves the short path form of a specified input path.
GetTempFileName Creates a name for a temporary file.
GetTempPath Retrieves the path of the directory designated for temporary files.
LockFile Locks a region in an open file.
LockFileEx Locks a region in an open file for shared or exclusive access.
MoveFile Moves an existing file or a directory.
MoveFileEx Moves an existing file or a directory.
MoveFileWithProgress Moves a file or directory.
PostQueuedCompletionStatus Posts an I/O completion packet to an I/O completion port.
QueryDosDevice Retrieves information about MS-DOS device names.
ReadDirectoryChangesW Retrieves information describing the changes occurring within a directory.
ReadFile Reads data from a file, starting at the specified position.
ReadFileEx Reads data from a file asynchronously.
ReadFileScatter Reads data from a file and stores the data into a set of buffers.
RemoveDirectory Deletes an existing empty directory.
ReplaceFile Replaces one file with another file.
SearchPath Searches for the specified file.
SetCurrentDirectory Changes the current directory for the current process.
SetEndOfFile Moves the end-of-file position for the specified file.
SetFileApisToANSI Causes the file I/O functions to use the ANSI character set code page.
SetFileApisToOEM Causes the file I/O functions to use the OEM character set code page.
SetFileAttributes Sets a file's attributes.
SetFilePointer Moves the file pointer of an open file.
SetFilePointerEx Moves the file pointer of an open file.
SetFileSecurity Sets the security of a file or directory object.
SetFileShortName Sets the valid data length of the specified file.
SetFileValidData Sets the valid data length of the specified file.
SetVolumeLabel Sets the label of a file system volume.
UnlockFile Unlocks a previously locked region in an open file.
UnlockFileEx Unlocks a previously locked region in an open file.
WriteFile Writes data to a file.
WriteFileEx Writes data to a file asynchronously.
WriteFileGather Gathers data from a set of buffers and writes the data to a file.
ilovevc 2004-12-30
  • 打赏
  • 举报
回复
mfc有个CFileFind 类,如果不想用mfc,你可以看看它的源代码,里面到底调用了什么。

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧