本文整理汇总了C++中CFile::Remove方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::Remove方法的具体用法?C++ CFile::Remove怎么用?C++ CFile::Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::Remove方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmptyDir
void MusicUtils::EmptyDir(CString Dir)
{
CFileFind finder;
CFile cfile;
CString Add=L"\\*";
CString DirSpec=Dir+Add; //????????????
BOOL bWorking = finder.FindFile(DirSpec);
while (bWorking)
{
bWorking = finder.FindNextFile();
if(!finder.IsDots()) //????????
{
if(finder.IsDirectory()) //????????
{
CString strDirectory = finder.GetFilePath();
if(_rmdir((const char*)(LPSTR)(LPCTSTR)strDirectory)==-1)
{
EmptyDir(strDirectory);
}
bWorking = finder.FindFile(DirSpec);
}
else //???????
{
cfile.Remove(finder.GetFilePath());
}
}
}
finder.Close();
}
示例2: ClearProfile
void CProfile::ClearProfile()
{
CFile file;
// delete the XML file
file.Remove(m_strDataFullPath);
}
示例3:
void CDatabaseDlg2::OnBnClickedDeleteFace()
{
// TODO: 在此添加控件通知处理程序代码
int nIndex;
CString id,fpath;
CDatabase db;
db.Open(NULL, FALSE, FALSE, _T("ODBC;DSN=face;UID=root;PWD=root"));
nIndex = m_list.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
//if(-1 == nIndex)
// nIndex = 0;
if(-1 != nIndex)
{
id = m_list.GetItemText(nIndex,0);
fpath = m_list.GetItemText(nIndex,4);
}
else
{
MessageBox("请选择要删除人脸!");
db.Close();
return;
}
//删除文件
CFileFind finder;
if(finder.FindFile(fpath))
{
CFile TempFile;
TempFile.Remove(fpath);
}
CString sql;
sql.Format("delete from face where ID=%s", id);
db.ExecuteSQL(sql);
db.Close();
CString cmdStr = "Select * from face order by ID";
m_sname.SetWindowText("");
m_spath.SetWindowText("");
m_fname.SetWindowText("");
m_fpath.SetWindowText("");
ShowDatabase(cmdStr);
MessageBox("删除成功");
}
示例4: SplitOneFileToManyFiles
void CExportData::SplitOneFileToManyFiles(CString Dir,CString DestFileName,bool bDayKline)
{
CFile SrcFile;
CString sExd = ".day";
if(bDayKline==false)
sExd=".min";
if(!SrcFile.Open(DestFileName,CFile::modeRead))
{
AfxMessageBox("打开文件出错!");
return;
}
int LengthOfSrcFile=SrcFile.GetLength();
int BytesPerDisk=1457000;
int NumOfDisks= LengthOfSrcFile%BytesPerDisk==0 ? LengthOfSrcFile/BytesPerDisk:LengthOfSrcFile/BytesPerDisk+1;
for (int nDisk=1;nDisk<=NumOfDisks;nDisk++)
{
int nSize=min(BytesPerDisk,LengthOfSrcFile);
if( nSize<= 0)
{
return;
}
CString DiskXFileName;
DiskXFileName.Format("%d",nDisk);
DiskXFileName=Dir+"\\TL_Disk"+DiskXFileName+sExd;
CFile DiskXFile( DiskXFileName,CFile::modeCreate|CFile::modeWrite);
DiskXFile.Write(&NumOfDisks,sizeof(4));
DiskXFile.Write(&nDisk,sizeof(4));
BYTE *Buffer=new BYTE[nSize];
SrcFile.Read(Buffer,nSize);
DiskXFile.Write(Buffer,nSize);
delete []Buffer;
DiskXFile.Close();
LengthOfSrcFile-=nSize;
}
SrcFile.Close();
SrcFile.Remove(DestFileName);
}
示例5: OnInitDialog
//.........这里部分代码省略.........
ACPI.SetDlgItemText(IDC_time_to_run,_T("-"));
ACPI.SetDlgItemText(IDC_PBUTTON,_T("Pause"));
ACPI.SetDlgItemText(IDC_S3BUTTON,_T("Run S1/S3"));
ACPI.SetDlgItemText(IDC_S4BUTTON,_T("Run S4"));
ACPI.SetDlgItemText(IDC_S5BUTTON,_T("Run S5"));
ACPI.SetDlgItemText(IDC_RbBUTTON, _T("Reboot"));
ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(FALSE);
ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(TRUE);
ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(TRUE);
ACPI.GetDlgItem(IDC_S5BUTTON)->EnableWindow(TRUE);
ACPI.GetDlgItem(IDC_RbBUTTON)->EnableWindow(TRUE);
}
//copycompare
CCTool.CheckDlgButton(IDC_200MS_RADIO, 1);
CCTool.sourcepath = _T("D:\\CCData\\200MS");
CCTool.SetDlgItemText(IDC_SOURCE_PATH_EDIT,CCTool.sourcepath);
CString filename ;
TCHAR SysTmpPath[MAX_PATH];
GetTempPath(MAX_PATH,SysTmpPath);
filename = SysTmpPath;
filename+=_T("CCtool.bat");
CFileFind finder;
BOOL iffind = finder.FindFile(filename);
if(iffind)
{
CFile CCbat;
CCbat.Remove(filename);
}
CFile CCbat(filename, CFile::modeCreate|CFile::modeWrite);
CCbat.Write("@echo off\r\necho CCLoop will start running in 10 seconds...\r\n", sizeof("@echo off\r\necho CCLoop will start running in 10 seconds...\r\n")-1);
CCbat.Write("ping 127.0.0.1 -n 11>nul\r\n",sizeof("ping 127.0.0.1 -n 11>nul\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write("set /a looptime=0\r\n",sizeof("set /a looptime=0\r\n")-1);
CCbat.Write("set sdisk=%2\r\n",sizeof("set sdisk=%2\r\n")-1);
CCbat.Write("set ddisk=%3\r\n",sizeof("set ddisk=%3\r\n")-1);
CCbat.Write("set s=%sdisk:~0,1%\r\n",sizeof("set s=%sdisk:~0,1%\r\n")-1);
CCbat.Write("set d=%ddisk:~0,1%\r\n",sizeof("set d=%ddisk:~0,1%\r\n")-1);
CCbat.Write("if not exist %d%:\\ color fc&echo ERROR!!! %d%:\\ is not EXIST!!!&pause\r\n",sizeof("if not exist %d%:\\ color fc&echo ERROR!!! %d%:\\ is not EXIST!!!&pause\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write("path=c:\\;c:\\windows\\command;c:\\windows\\system32;c:\\windows;C:\\WinNT\\system32;c:\\WinNT;c:\\windows\\sysWOW64;\r\n",sizeof("path=c:\\;c:\\windows\\command;c:\\windows\\system32;c:\\windows;C:\\WinNT\\system32;c:\\WinNT;c:\\windows\\sysWOW64;\r\n")-1);
CCbat.Write("break=on\r\n",sizeof("break=on\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write("if exist c:\\%s%-%d%-%1.txt del /q c:\\%s%-%d%-%1.txt\r\n",sizeof("if exist c:\\%s%-%d%-%1.txt del /q c:\\%s%-%d%-%1.txt\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write(":start\r\n",sizeof(":start\r\n")-1);
CCbat.Write("echo ************** (%s%) copy to (%d%) is starting ******************* >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************** (%s%) copy to (%d%) is starting ******************* >>C:\\%s%-%d%-%1.txt\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write(":l\r\n",sizeof(":l\r\n")-1);
CCbat.Write("if exist %3 rd /s /q %3\r\n",sizeof("if exist %3 rd /s /q %3\r\n")-1);
CCbat.Write("if exist D:\\%d%-%1-C rd /s /q D:\\%d%-%1-C\r\n",sizeof("if exist D:\\%d%-%1-C rd /s /q D:\\%d%-%1-C\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write(":loop\r\n",sizeof(":loop\r\n")-1);
CCbat.Write("echo ************************************************************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************************************************************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
CCbat.Write("echo ************** Loop %looptime% is starting ****************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************** Loop %looptime% is starting ****************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
CCbat.Write("md %3\r\n",sizeof("md %3\r\n")-1);
CCbat.Write("echo %time%\r\n",sizeof("echo %time%\r\n")-1);
CCbat.Write("\r\n",sizeof("\r\n")-1);
示例6: FloppyFile
void CExportData::Produce2FloppyDisk(CString DestFileName,CString FloppyFileName)
{
CFile SrcFile;
if(!SrcFile.Open(DestFileName,CFile::modeRead))
{
AfxMessageBox("打开文件出错!");
return;
}
int LengthOfSrcFile=SrcFile.GetLength();
int BytesPerDisk=1457000;
int NumOfDisks=LengthOfSrcFile%BytesPerDisk==0?LengthOfSrcFile/BytesPerDisk:LengthOfSrcFile/BytesPerDisk+1;
CString str;
str.Format("%d",NumOfDisks);
str="要导出到软盘上, 大约需要 " + str + " 张软盘(3.5寸)。";
if( AfxMessageBox(str,MB_OKCANCEL)==IDCANCEL )
{
SrcFile.Close();
SrcFile.Remove(DestFileName);
return;
}
DWORD SectorsPerCluster,BytesPerSector,NumberOfFreeClusters,TotalNumberOfClusters;
for(int nDisk=1;nDisk<=(NumOfDisks+1);nDisk++)
{
int nSize=min(BytesPerDisk,LengthOfSrcFile);
if(nSize<=0)
{
SrcFile.Close();
SrcFile.Remove(DestFileName);
return;
}
str.Format("%d",nDisk);
str="请插入第 "+str+" 张软盘。";
if( AfxMessageBox(str,MB_OKCANCEL)==IDCANCEL )
{
SrcFile.Close();
SrcFile.Remove(DestFileName);
return;
}
::GetDiskFreeSpace(FloppyFileName.Mid(0,2),&SectorsPerCluster,&BytesPerSector,&NumberOfFreeClusters,&TotalNumberOfClusters);
int FreeSpacePerDisk=NumberOfFreeClusters*SectorsPerCluster*BytesPerSector;
while(FreeSpacePerDisk<(BytesPerDisk+8))
{
AfxMessageBox("请删除磁盘上的所有数据,或者格式化磁盘。按确定继续导出!",MB_ICONASTERISK);
::GetDiskFreeSpace(FloppyFileName.Mid(0,2),&SectorsPerCluster,&BytesPerSector,&NumberOfFreeClusters,&TotalNumberOfClusters);
FreeSpacePerDisk=NumberOfFreeClusters*SectorsPerCluster*BytesPerSector;
//return;
}
CFile FloppyFile(FloppyFileName,CFile::modeCreate|CFile::modeWrite);
FloppyFile.Write(&NumOfDisks,sizeof(4));
FloppyFile.Write(&nDisk,sizeof(4));
BYTE *Buffer=new BYTE[nSize];
SrcFile.Read(Buffer,nSize);
FloppyFile.Write(Buffer,nSize);
delete []Buffer;
FloppyFile.Close();
LengthOfSrcFile-=nSize;
}
SrcFile.Close();
SrcFile.Remove(DestFileName);
}
示例7: IsDirectoryExist
BOOL CExportData::IsDirectoryExist()
{
CFileFind finder;
BOOL bWorking;
CString Filepath,FileName,strNl;
CFile DeleFile;
CString GetUserPath;
m_destination.GetWindowText(GetUserPath);
GetUserPath.TrimRight("\\");
GetUserPath+="\\";
if(((CComboBox*)GetDlgItem(1011))->GetCurSel()==0)
{
FileName="导出1分钟二进制数据";
strNl=".1mn";
}
if(((CComboBox*)GetDlgItem(1011))->GetCurSel()==1)
{
FileName="导出1分钟文本数据";
strNl=".txt";
}
if(((CComboBox*)GetDlgItem(1011))->GetCurSel()==2)
{
FileName="导出1分钟EXCEL数据";
strNl=".xls";
}
if (!(bWorking=finder.FindFile(GetUserPath+FileName+"\\*.*") ) )
if(!(::CreateDirectory(GetUserPath+ FileName,NULL)))
{
AfxMessageBox("路径中包括错误的路径,请重新设置!");
m_destination.SetFocus();
return 1;
}
if(bWorking)
if( AfxMessageBox("存在同名文件,是否覆盖?",MB_ICONQUESTION|MB_YESNO )==IDNO )
return 1;
if ( !(bWorking=finder.FindFile(GetUserPath+FileName+"\\沪A\\"+strNl) ) )
::CreateDirectory(GetUserPath+ FileName+"\\沪A",NULL);
while(bWorking)
{
bWorking=finder.FindNextFile();
Filepath=finder.GetFilePath();
DeleFile.Remove(Filepath);
}
if ( !(bWorking=finder.FindFile(GetUserPath+FileName+"\\沪B\\"+strNl) ))
::CreateDirectory( GetUserPath+FileName+"\\沪B",NULL);
else while(bWorking)
{
bWorking=finder.FindNextFile();
Filepath=finder.GetFilePath();
DeleFile.Remove(Filepath);
}
if ( !(bWorking= finder.FindFile(GetUserPath+FileName+"\\沪指\\"+strNl) ))
::CreateDirectory( GetUserPath+ FileName+"\\沪指",NULL);
else while(bWorking)
{
bWorking=finder.FindNextFile();
Filepath=finder.GetFilePath();
DeleFile.Remove(Filepath);
}
if ( !(bWorking= finder.FindFile(GetUserPath+FileName+"\\沪债\\"+strNl) ))
::CreateDirectory( GetUserPath+FileName+"\\沪债",NULL);
else while(bWorking)
{
bWorking=finder.FindNextFile();
Filepath=finder.GetFilePath();
DeleFile.Remove(Filepath);
}
if ( !(bWorking= finder.FindFile(GetUserPath+FileName+"\\深A\\"+strNl) ))
::CreateDirectory(GetUserPath+ FileName+"\\深A",NULL);
else while(bWorking)
{
bWorking=finder.FindNextFile();
Filepath=finder.GetFilePath();
DeleFile.Remove(Filepath);
}
if ( !(bWorking= finder.FindFile(GetUserPath+FileName+"\\深B\\"+strNl) ))
::CreateDirectory( GetUserPath+ FileName+"\\深B",NULL);
else while(bWorking)
{
bWorking=finder.FindNextFile();
Filepath=finder.GetFilePath();
DeleFile.Remove(Filepath);
}
if ( !(bWorking= finder.FindFile(GetUserPath+FileName+"\\深指\\"+strNl) ))
::CreateDirectory(GetUserPath+ FileName+"\\深指",NULL);
else while(bWorking)
{
bWorking=finder.FindNextFile();
//.........这里部分代码省略.........
示例8: deleteTempFile
static int deleteTempFile(void)
{
CFile TempFile;
TempFile.Remove(SVN_LOG_FILE);
return 0;
}
示例9: InternetGetFile
//.........这里部分代码省略.........
{
tempath[len*sizeof(TCHAR)+1]='\0';
}
TCHAR tempname[MAX_PATH+1];
if(!::GetTempFileName(tempath,TEXT("bzw"),0,tempname))
{
return -1;
}
Fullpath=tempname;
}
//获取目标全路径不包括文件名
path=Fullpath;
cur=path.ReverseFind('\\');
destname=path;
path=destname.Mid(cur+1,destname.GetLength()-1-cur);
destname=Fullpath;
if(filename)
filename=destname;
DWORD dwFlags;
InternetGetConnectedState(&dwFlags, 0);
TCHAR strAgent[64];
memset(strAgent,0,sizeof(strAgent));
wsprintf(strAgent, TEXT("Agent%ld"), timeGetTime());
HINTERNET hOpen;
if(!(dwFlags & INTERNET_CONNECTION_PROXY))
hOpen = InternetOpen(strAgent, INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0);
else
hOpen = InternetOpen(strAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if(!hOpen)
{//显示错误信息
return -1;
}
DWORD dwSize;
TCHAR szHead[] = TEXT("Accept: */*\r\n\r\n");
VOID* szTemp[16384];
HINTERNET hConnect;
CFile file;
if ( !(hConnect = InternetOpenUrl( hOpen, szUrl, szHead,
lstrlen(szHead), INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0)))
{//显示错误信息
InternetCloseHandle(hOpen);
return -1;
}
bool CreateDir=false;
retry:
if(file.Open(destname.GetBuffer(),CFile::modeWrite|CFile::modeCreate)==FALSE)
{//显示错误信息
int err=GetLastError();
if(!CreateDir)
{//创建目录,然后重试
::CreateDirectory(path.GetBuffer(),NULL);
CreateDir = true;
goto retry;
}
return -1;
}
DWORD dwByteToRead = 0;
DWORD dwSizeOfRq = 4;
DWORD dwBytes = 0;
if (!HttpQueryInfo(hConnect, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwByteToRead, &dwSizeOfRq, NULL))
{
dwByteToRead = 0;
}
memset(szTemp,0,sizeof(szTemp));
do
{
if(false)
{
file.Close();
file.Remove(destname.GetBuffer());
InternetCloseHandle(hConnect);
InternetCloseHandle(hOpen);
return -1;
}
if (!InternetReadFile (hConnect, szTemp, 16384, &dwSize))
{//显示错误信息
file.Close();
file.Remove(destname.GetBuffer());
InternetCloseHandle(hConnect);
InternetCloseHandle(hOpen);
return -1;
}
if (dwSize==0)
break;
else
{
file.Write(szTemp,dwSize);
}
}while (TRUE);
file.Close();
InternetCloseHandle(hConnect);
InternetCloseHandle(hOpen);
return 0;
}
示例10: OutChuQuanData
void CChuquanData::OutChuQuanData(CString FilePath)
{
::SetCurrentDirectory(pDoc->m_CurrentWorkDirectory);
UpdateData(TRUE);
CFile OutFile;
if(!OutFile.Open(FilePath,CFile::modeCreate|CFile::modeWrite,NULL))
{
MessageBox("导出除权信息失败!","警告",MB_OK|MB_ICONEXCLAMATION);
return;
}
int nHeaderFlag=-1;
int nTotalCount=0;
POWER Power;
struct POWER_1th
{
BYTE byFree[8];
int nFlags;
int nTime;
float fGive;
float fAllocate;
float fAllocatePrice;//行情数据结构数组类实现
float fDividend;
};
POWER_1th Power_1th;
int nSplitMask=-1;
//int FileId=FILEID22;
//OutFile.Write(&FileId,4);
OutFile.Seek(8,CFile::begin);
for(int nStockType=0;nStockType<8;nStockType++)
{
for(int i=0;i<pDoc->m_sharesInformation.GetStockTypeCount(nStockType);i++)
{
CReportData *pDat1=NULL;
pDoc->m_sharesInformation.GetStockItem(nStockType,i,pDat1);
if(pDat1)
{
if(pDat1->pBaseInfo)
{
if(pDat1->pBaseInfo->NumSplit>0)
{
nTotalCount++;
OutFile.Write(&nSplitMask,sizeof(int));
OutFile.Write(&(pDat1->id),8*sizeof(char));
int a =pDat1->kind;
OutFile.Write(&a,4);
for(int j=0;j<pDat1->pBaseInfo->NumSplit;j++)
{
memcpy(&Power,&(pDat1->
pBaseInfo->m_Split[j]),sizeof(POWER));
Power_1th.fAllocate=Power.fAllocate;
Power_1th.fAllocatePrice=Power.fAllocatePrice;
Power_1th.fDividend=Power.fDividend;
Power_1th.fGive=Power.fGive;
Power_1th.nTime=Power.nTime;
OutFile.Write(&Power_1th,sizeof(POWER_1th));
}
}
}
}
}
}
OutFile.Close();
// }
if(nTotalCount==0)
{//数据文件读写实现
AfxMessageBox("没有除权数据!",MB_ICONASTERISK);
OutFile.Remove(FilePath);
}
else
AfxMessageBox("导出完毕!",MB_ICONASTERISK);
}