C语言里怎么读取文件信息
C语言里如何读取文件信息?
就是这个文件大小,创建时间之类的信息,怎么去读取?
------解决方案--------------------
_stat, _wstat, _stati64, _wstati64
Get status information on a file.
int _stat( const char *path, struct _stat *buffer );
__int64 _stati64( const char *path, struct _stat *buffer );
int _wstat( const wchar_t *path, struct _stat *buffer );
__int64 _wstati64( const wchar_t *path, struct _stat *buffer );
Routine Required Header Optional Headers Compatibility
_stat <sys/types.h> followed by <sys/stat.h> <errno.h> Win 95, Win NT
_wstat <sys/types.h> followed by <sys/stat.h> or <wchar.h> <errno.h> Win NT
_stati64 <sys/types.h> followed by <sys/stat.h> <errno.h> Win 95, Win NT
_wstati64 <sys/types.h> followed by <sys/stat.h> or <wchar.h> <errno.h> Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
Each of these functions returns 0 if the file-status information is obtained. A return value of –1 indicates an error, in which case errno is set to ENOENT, indicating that the filename or path could not be found.
Parameters
path
Path of existing file
buffer
Pointer to structure that stores results
Remarks
The _stat function obtains information about the file or directory specified by path and stores it in the structure pointed to by buffer. _stat automatically handles multibyte-character string arguments as appropriate, recognizing multibyte-character sequences according to the multibyte code page currently in use.
就是这个文件大小,创建时间之类的信息,怎么去读取?
------解决方案--------------------
_stat, _wstat, _stati64, _wstati64
Get status information on a file.
int _stat( const char *path, struct _stat *buffer );
__int64 _stati64( const char *path, struct _stat *buffer );
int _wstat( const wchar_t *path, struct _stat *buffer );
__int64 _wstati64( const wchar_t *path, struct _stat *buffer );
Routine Required Header Optional Headers Compatibility
_stat <sys/types.h> followed by <sys/stat.h> <errno.h> Win 95, Win NT
_wstat <sys/types.h> followed by <sys/stat.h> or <wchar.h> <errno.h> Win NT
_stati64 <sys/types.h> followed by <sys/stat.h> <errno.h> Win 95, Win NT
_wstati64 <sys/types.h> followed by <sys/stat.h> or <wchar.h> <errno.h> Win NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
Return Value
Each of these functions returns 0 if the file-status information is obtained. A return value of –1 indicates an error, in which case errno is set to ENOENT, indicating that the filename or path could not be found.
Parameters
path
Path of existing file
buffer
Pointer to structure that stores results
Remarks
The _stat function obtains information about the file or directory specified by path and stores it in the structure pointed to by buffer. _stat automatically handles multibyte-character string arguments as appropriate, recognizing multibyte-character sequences according to the multibyte code page currently in use.