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
{
}