关于获得文件大小的问题

wq2003 2003-10-21 10:52:55
msdn中关于获得文件大小的函数如下:
CFile::GetLength
virtual DWORD GetLength( ) const;
throw( CFileException );

Return Value

The length of the file.

Remarks

Obtains the current logical length of the file in bytes, not the amount.

它的解释是获得文件的逻辑长度,而不是全部,不知怎么获得文件的实际长度
...全文
92 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wq2003 2003-10-21
  • 打赏
  • 举报
回复
GetFileSize不是用于vc的
我需要的是vc的
wilehorse 2003-10-21
  • 打赏
  • 举报
回复
GetFileSize

The GetFileSize function retrieves the size, in bytes, of a specified file.

This function stores the file size in a DWORD value. To retrieve a file size that is larger than a DWORD value, use the GetFileSizeEx function.

DWORD GetFileSize(
HANDLE hFile, // handle to file
LPDWORD lpFileSizeHigh // high-order word of file size
);
Parameters
hFile
[in] Handle to the file whose size is to be returned. This handle must have been created with either GENERIC_READ or GENERIC_WRITE access to the file.
lpFileSizeHigh
[out] Pointer to the variable where the high-order word of the file size is returned. This parameter can be NULL if the application does not require the high-order word.
Return Values
If the function succeeds, the return value is the low-order doubleword of the file size, and, if lpFileSizeHigh is non-NULL, the function puts the high-order doubleword of the file size into the variable pointed to by that parameter.

If the function fails and lpFileSizeHigh is NULL, the return value is -1. To get extended error information, call GetLastError.

If the function fails and lpFileSizeHigh is non-NULL, the return value is -1 and GetLastError will return a value other than NO_ERROR.

gomi 2003-10-21
  • 打赏
  • 举报
回复
我的理解是修改文件或打开共享文件,文件的大小是变化的,
GetLength取的是当时文件的大小或当时映射的文件的大小
flykissme 2003-10-21
  • 打赏
  • 举报
回复
_stat
用MSDN查查
smallcrocodile 2003-10-21
  • 打赏
  • 举报
回复
GetFileSize
GetFileSizeEx

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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