Posted on 2012-11-26 11:00
盛勝 閱讀(969)
評論(0) 編輯 收藏 引用
//創建文件夾
CString strFolderPath="c:\\deletetest.sql" ;
// 判斷路徑是否存在
if (!PathIsDirectory(strFolderPath) )
{
CString strMsg;
strMsg.Format ("指定路徑\"%s\"不存在,是否創建?",strFolderPath);
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
{
if (!CreateDirectory(strFolderPath, NULL ) )
{
strMsg.Format ("創建路徑\"%s\"失??!是否繼續?",strFolderPath);
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
return;
}
}
}
//創建并寫入文件
/* fopen example */
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen ("myfile.txt","w");
if (pFile!=NULL)
{
fputs ("fopen example",pFile);
fclose (pFile);
}
return 0;
}
//刪除文件
1.
system( "del c:\\DBControlRun_deletefun.sql" );
2.
isError=(int)ShellExecute(dbControlrunDlg.hWnd,
NULL,
_T("cmd"),
_T("/K del c:\\DBControlRun_deletefun.sql"),
NULL,
SW_HIDE);