拷贝文件需要那么麻烦么?
用下边的函数一下就搞定了(WIN API)
#include windows.h
BOOL CopyFile(
  LPCTSTR lpExistingFileName, // name of an existing file
  LPCTSTR lpNewFileName,      // name of new file
  BOOL bFailIfExists          // operation if file exists
);
Parameters
lpExistingFileName 
[in] Pointer to a null-terminated string that specifies the name of an existing file. 
lpNewFileName 
[in] Pointer to a null-terminated string that specifies the name of the new file. 
bFailIfExists 
[in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. 

解决方案 »

  1.   

    且不说你的方法太麻烦,错误应该在这里:
    char  strSrc[]="c:\\dos\0";
    char  strDst[]="c:\\temp\0";
    char  strTitle[]="COPY文件"; 
    strcpy(,(LPCSTR)delfile);//???按照char  strSrc[]="c:\\dos\0",SstrSrc的长度只有7,而你的delfile长度超过7必定发生数据越界。应该保证strSrc的长度绝对大于delfile
    strcat(strSrc,"\0");//原字符串为空,此句并没有进行任何操作,假如不需要有两个NULL结尾,这是不需要的,真的需要,必须改为strSrc[strlen(strSrc)+1]=NULL。同时必须注意数据是否越界。
      

  2.   

    Faint!
    你为什么不用CString呢?如果真的不想用CString,你在定义文件名变量时应该定义为char szSrc[MAX_PATH],MAX_PATH为最大的目录长度,这个宏已经定已过了,不用你管。
      

  3.   

    就是用CString delfile;才会出错,而用char strSrc[]=“filepaht\0";则一点问题都没有,
    FileOp.pFrom=strSrc;FileOp.pTo=strDst;要求两个NULL结尾,怎样用CString 作为文件名
    变量?