目的文件夹个格式是:目录名以日期格式   文件名以时间格式
如   MSG/JS/2011-10-28/10_37_21.txt请指教啊~~~~

解决方案 »

  1.   

    先获取时间等GetLocalTime,然后CString Format拼接目录路径,然后CreateDirectory创建所有目录,再CopyFIle复制文件
      

  2.   

    类似这样?
    TCHAR szExtName[40]={0},szPaths[260]={0};
    GetPath(szPaths,260);
    _tcscat(szPaths,TEXT("History\\"));
    SYSTEMTIME st;
    ::GetLocalTime(&st);
    _stprintf(szExtName,TEXT("%04d%02d%02d%02d%02d%02d.xml"),st.wYear,
    st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
    _tcscat(szPaths,hParent->szModuleName);
    _tcscat(szPaths,szExtName);
      

  3.   

    回复 oyljerry复制的内容是报文格式的ZCZC
    SAC140 BTNT 031601 这样的数据
    要拷贝到的目的文件路径是MSG/JS/2011-10-28/10_37_21.txt
    你能写的具体点么,有什么代码参考么
      

  4.   


    回复 xuddk727应该不是这样的把。 就是把报文数据,拷贝到指定的当前时间目录文件夹的下面(MSG/JS/2011-10-28/10_37_21.txt)
    。不知道Copyfile 能不能用
      

  5.   

    确保目录正确 CopyFile 
      

  6.   

       CTime t = CTime::GetCurrentTime();
    //组合目录名称 
    //文件名前缀 = MSG/JS
    CString cyear = t.Format("%Y-%m-%d");
    cyear = "c:\\MSG\\JS\\"+cyear+"\\";
    CString ctime = t.Format("%H_%M_%S");
    ctime += ".txt";
    CFile f(cyear+ctime,CFile::modeCreate|CFile::modeReadWrite);
    f.Write("test\n\r",6);
    f.Close();

      

  7.   

    //判断"d:\\Belson"是否存在,如果不存在则创建文件夹
    DWORD dwAttr = GetFileAttributes(szFindPath);
    if(dwAttr == 0xFFFFFFFF)     //文件夹不存在
    {
    CreateDirectory(szFindPath,NULL);  
    }
    // 然后再CopyFile