locked
SHFileOperation failing!!!! RRS feed

  • Question

  • Hi all

    I was trying to copy a directory along with its contents using the SHFileOperation api as follows.

    SHFILEOPSTRUCT st_FileOp;

    memset (&st_FileOp, 0x00, sizeof(st_FileOp));

    st_FileOp.wFunc = FO_COPY ;

    st_FileOp.hwnd = hDlg;

    st_FileOp.fFlags = FOF_ALLOWUNDO | FOF_MULTIDESTFILES | FOF_NOCONFIRMMKDIR | FOF_NOCONFIRMATION;

    st_FileOp.pFrom = L"/My Documents/New Folder/*\0";

    st_FileOp.pTo = L"/Temp\0" ;

    if(!SHFileOperation(&st_FileOp))

    {

    MessageBox(NULL,L"Copied",L"Done",MB_OK);

    }

    else

    {

    MessageBox(NULL,L"Copy Failed",L"Not Done",MB_OK);

    }

    But i am getting an error: error code 183:"Cannot create a file when that file already exists." ERROR_ALREADY_EXISTS. But the file or directory does not exist at the destination end.

    Please let me know what is wrong with the code.

    thanks in advance

    mahesh.:)

     

     

    Friday, November 3, 2006 9:30 AM

All replies

  • probably because you do not specific the correct path name

    try this

    st_FileOp.pFrom = L"\\My Documents\\New Folder\\*.*\0";

    st_FileOp.pTo = L"\\Temp\\\0";

    Friday, November 3, 2006 11:24 AM
  • hi

    I tried with above mentioned changes, but dint help!!!

    Please let me know what flag values i must use and format of the to from fields.

    --mahesh.

    Monday, November 6, 2006 10:19 AM