Compartilhar via


CFile::SetStatus

Sets the status of the file associated with this file location.

static void PASCAL SetStatus(
   LPCTSTR lpszFileName,
   const CFileStatus& status,
   CAtlTransactionManager* pTM = NULL
);

Parameters

  • lpszFileName
    A string that is the path to the desired file. The path can be relative or absolute, and can contain a network name.

  • status
    The buffer containing the new status information. Call the GetStatus member function to prefill the CFileStatus structure with current values, then make changes as required. If a value is 0, then the corresponding status item is not updated. See the GetStatus member function for a description of the CFileStatus structure.

  • pTM
    Pointer to CAtlTransactionManager object

Remarks

To set the time, modify the m_mtime field of status.

Please note that when you make a call to SetStatus in an attempt to change only the attributes of the file, and the m_mtime member of the file status structure is nonzero, the attributes may also be affected (changing the time stamp may have side effects on the attributes). If you want to only change the attributes of the file, first set the m_mtime member of the file status structure to zero and then make a call to SetStatus.

Example

TCHAR* pFileName = _T("ReadOnly_File.dat");
CFileStatus status;
CFile::GetStatus(pFileName, status);
status.m_attribute |= CFile::readOnly;
CFile::SetStatus(pFileName, status);         

Requirements

Header: afx.h

See Also

Reference

CFile Class

Hierarchy Chart

CFile::GetStatus

Other Resources

CFile Members