Posted on 2012-11-26 11:00
盛胜 阅读(961)
评论(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);