我想用程序建立一个文件,
 CString kk="E:\\30\\1.mp4";
  sprintf(fileName,kk);
m_gFileHandle[nSlot]=_open(fileName, _O_CREAT | _O_BINARY | _O_WRONLY| _O_TRUNC, _S_IREAD | _S_IWRITE);
if(m_gFileHandle[nSlot] == -1)
{
TRACE("file open error\n");
AfxMessageBox("can not open file\n");
}
但是打不开,如设kk="E:\\30.mp4“;可以成功,我不知为什么,望大哥们指点

解决方案 »

  1.   

    改成这样:CString kk="E:\\30\\1.mp4";
    m_gFileHandle[nSlot]=_open(kk, _O_CREAT | _O_BINARY | _O_WRONLY| _O_TRUNC, _S_IREAD | _S_IWRITE);
    if(m_gFileHandle[nSlot] == -1)
    {
    TRACE("file open error\n");
    AfxMessageBox("can not open file\n");
    }
      

  2.   

    open函数不能建立一个不存在的目录。只能打开目录下的文件。