本文整理汇总了C++中CFileException::Delete方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileException::Delete方法的具体用法?C++ CFileException::Delete怎么用?C++ CFileException::Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileException
的用法示例。
在下文中一共展示了CFileException::Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddNewFile
bool CZipArchive::AddNewFile(LPCTSTR lpszBasePath, LPCTSTR lpszFilePath, int iLevel, unsigned long nBufSize)
{
if (!nBufSize)
return false;
CFileHeader header;
if( lpszBasePath )
{
header.m_szFileName = GetFileDirAndName(lpszFilePath);
CString basepath = GetFileDirAndName(lpszBasePath);
header.m_szFileName.Replace( basepath, _T("") );
}
else
{
header.m_szFileName = GetFileDirAndName(lpszFilePath);
}
if (header.m_szFileName.IsEmpty())
return false;
if (!OpenNewFile(header, iLevel, lpszFilePath))
return false;
if (!IsDirectory(header.m_uExternalAttr))
{
CFile f;
CFileException* e = new CFileException;
BOOL bRet = f.Open(lpszFilePath, CFile::modeRead | CFile::shareDenyWrite, e);
e->Delete();
if (!bRet)
return false;
DWORD iRead;
CAutoBuffer buf(nBufSize);
do
{
iRead = f.Read(buf, nBufSize);
if (iRead)
WriteNewFile(buf, iRead);
}
while (iRead == buf.GetSize());
}
CloseNewFile();
return true;
}
示例2: CheckInstallDate
//.........这里部分代码省略.........
{
if( UEGetSettingInstallNumber("1", 0) >= INSTALL_NUM )
{
//如果安装次数超过
glngUseDemoVersionDays = glngLimitedDemoVersionDays + 1;
}
else
{
//如果时间超过,则演示版功能受到限制
if( glngLimitedDemoVersionDays > RUN_DAYS_NUM )
glngLimitedDemoVersionDays = RUN_DAYS_NUM;
else if( glngLimitedDemoVersionDays <= 0 )
glngLimitedDemoVersionDays = RUN_DAYS_NUM;
else
glngLimitedDemoVersionDays = RUN_DAYS_NUM;
COleDateTime Date=COleDateTime::GetCurrentTime();
COleDateTime dateTmp = Qsort.sortarray[iNum-1];
if(Date >= dateTmp )
{
dateTmp=Qsort.sortarray[0];
if( Date >= dateTmp)
{
glngUseDemoVersionDays = Date - COleDateTime(Qsort.sortarray[1]);
}
else
{
glngUseDemoVersionDays = glngLimitedDemoVersionDays + 1;//因为用户自已调整了时间所以让演示版到期
tmpD=(DATE)InsDate;
f.Write(&tmpD,sizeof(DATE));
}
}
else
{
glngUseDemoVersionDays = glngLimitedDemoVersionDays + 1;//因为用户自已调整了时间所以让演示版到期
tmpD=(DATE)InsDate;
f.Write(&tmpD,sizeof(DATE));
}
}
if( glngUseDemoVersionDays >= glngLimitedDemoVersionDays )
{
f1.Open(user::gstrWinDir + FileOutDate,CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate);
Today=COleDateTime::GetCurrentTime();
tmpD=(DATE)Today;
f1.Write(&tmpD,sizeof(DATE));
f1.Close();
tmpD=0;
st=f.GetLength();
if(st>=16)
{
st=8;
f.Seek(st,CFile::begin);
f.Write(&tmpD,sizeof(DATE));
}
SetFileTime(user::gstrWinDir + FileWinCom, user::gstrWinDir + FileOutDate);
gbLegalUser = FALSE;
if( FileExists(user::gstrWinDir + FileFlag) )
DeleteFile(user::gstrWinDir + FileFlag);
}
else
{
if( UEGetSettingInstallNumber( "2", 0) >= RUN_NUM )
{
//如果运行次数超过
SetFileTime(user::gstrWinDir + FileWinCom, user::gstrWinDir + FileOutDate);
gbLegalUser = FALSE;
if( FileExists(user::gstrWinDir + FileFlag) )
DeleteFile( user::gstrWinDir + FileFlag);
}
else
{
if( UEGetSettingInstallNumber( "2", 0) < 0 )
{
UESaveSettingInstallNumber( "2", RUN_NUM);
gbLegalUser = FALSE;
}
else
{
CopyFile( user::gstrWinDir + FileWinCom, user::gstrWinDir + FileFlag,TRUE);
SetFileTime(user::gstrWinDir + FileWinCom, user::gstrWinDir + FileFlag);
gbLegalUser = TRUE;
}
}
}
}
else
{
gbLegalUser = FALSE;
if( FileExists(user::gstrWinDir + FileFlag) )
DeleteFile( user::gstrWinDir + FileFlag);
}
f.Close();
}
catch(CFileException *e)
{
e->ReportError();
e->Delete();
}
}