上一篇将了如何去获取一个文件的文件属性,那么我们有些时候还要对一个文件进行设置其文件属性值。
比方说:我在服务器上下载一个文件,我要求下载的文件属性要和服务器上的文件属性一致。
那么我们就要对下载后的文件进行修改其文件属性参数了。
那么怎么修改呢?
BOOL SetFileAttributes(time_t createTime, time_t accessTime, time_t modifyTime)
{
CFile cfile;
CFileStatus status;
if(!cfile.GetStatus(status))
{
//AfxMessageBox("获取文件属性失败!!!");
return false;
}
status.m_ctime = createTime;
status.m_atime = accessTime;
status.m_mtime = modifiTime;
status.m_attribute = 0x00; //文件正常(主要考虑权限问题)
try
{
cfile.SetStatus(strpath, status); //设置文件属性
}
catch(CFileException e)
{
char buf[256];
e.GetErrorMessage(buf,256);
//AfxMessageBox(buf);
return false;
}
return true;
}
好了,今天的修改文件属性就介绍到这里,如果大家有什么不懂的或者我哪里说错了请及时联系我,新浪邮箱:chao_song2011@sina.cn 不胜感激!!!