Export (0) Print
Expand All
2 out of 5 rated this helpful - Rate this topic

CFile::GetStatus 

This method retrieves status information related to a given CFile object instance or a given file path.


BOOL GetStatus(
   CFileStatus& rStatus 
) const;
static BOOL PASCAL GetStatus(
   LPCTSTR lpszFileName,
   CFileStatus& rStatus 
);

Parameters

rStatus

A reference to a user-supplied CFileStatus structure that will receive the status information. The CFileStatus structure has the following fields:

  • CTime m_ctime   The date and time the file was created.

  • CTime m_mtime   The date and time the file was last modified.

  • CTime m_atime   The date and time the file was last accessed for reading.

  • ULONGLONG m_size   The logical size of the file in bytes, as reported by the DIR command.

  • BYTE m_attribute   The attribute byte of the file.

  • char m_szFullName[_MAX_PATH]   The absolute filename in the Windows character set.

lpszFileName

A string in the Windows character set that is the path to the desired file. The path can be relative or absolute, or it can contain a network path name.

TRUE if the status information for the specified file is successfully obtained; otherwise, FALSE.

The non-static version of GetStatus retrieves status information of the open file associated with the given CFile object. The static version of GetStatus obtains the file status from a given file path without actually opening the file. This is useful for testing the existence and access rights of a file.

The m_attribute member of the CFileStatus structure refers to the file attribute set. The CFile class provides the Attribute enumeration type so file attributes can be specified symbolically:

enum Attribute {
   normal =    0x00,
   readOnly =  0x01,
   hidden =    0x02,
   system =    0x04,
   volume =    0x08,
   directory = 0x10,
   archive =   0x20
   };
//example for CFile::GetStatus
CFileStatus status;
extern CFile cfile;
if( cfile.GetStatus( status ) )    // non-static version
   {
      #ifdef _DEBUG
         afxDump << "File size = " << status.m_size << "\n";
      #endif
   }
char* pFileName = "test.dat";
if( CFile::GetStatus( pFileName, status ) )   // static version
   {
      #ifdef _DEBUG
         afxDump << "Full file name = " << status.m_szFullName << "\n";
      #endif
   }

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.