CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: SHFileOperation

  1. #1
    Join Date
    May 2002
    Posts
    3

    SHFileOperation

    I can not get SHFileOperation to rename a file the error I get is "Cannot rename file: Select only one file to rename, or use MS-Dos wildcards for example (*.txt) to rename a group of files with similar names." I have no idea where this error comes from because I am creating an explorer like listctrl and I only have one file selected to rename. Here is the code below, any help to solve this problem or working code to RENAME a file would be good. Thank you.


    // Get file paths
    ...

    // Set up structures
    memset(&sOpStruct, 0, sizeof(sOpStruct));
    sOpStruct.pFrom = strSource;
    sOpStruct.pTo = strTarget;
    sOpStruct.hwnd = GetSafeHwnd();
    sOpStruct.wFunc = FO_RENAME;
    sOpStruct.fFlags = FOF_ALLOWUNDO;
    sOpStruct.fAnyOperationsAborted = FALSE;
    sOpStruct.hNameMappings = NULL;
    sOpStruct.lpszProgressTitle = NULL;

    // Run
    if (!SHFileOperation(&sOpStruct))
    {
    }
    else
    {
    }

  2. #2
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658
    I guess that strSource or strTarget or both of them are incorrect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured