We have an application that is using the Cloud File Api to implement a OneDrive like product. The following workflow causes a problem
STEPS
- Navigate to a folder in windows explorer
- On another machine or via a web client, rename the folder that you are viewing in step 1
- Program receives a notification from the server that the folder has been renamed
What we do in response
Update the local operation system with a move/rename to reflect the server
Use SHChangeNotify to tell the operating system that the folder was renamed
What I expect to happen
The address bar in windows explorer is updated to the new name
What actually happens
The address bar will be updated in normal circumstances. However, if the path to the folder was > 260 characters, then the address bar is updated as shown bellow with the "\?" prefix as shown below
This might seem harmless but it is not because explorer behaves very badly when the explorer bar has that prefix. Most IO operations (ie. drag drop, etc) are either not allowed or don't work as expected.
It should also be noted that this is really only a problem if the folder being updated is the folder that is being viewed in explorer.
Code Sample
The code below represents what we are doing, GetExtendedPath() will append a "\?" in front of the path. This works for IO functions but doesn't have an affect on SHChangeNotify, it seems
Kernel32.MoveFile(oldPath.GetExtendedPath(), newPath.GetExtendedPath());
SHChangeNotify(SHCNE_RENAMEFOLDER, SHCNF.SHCNF_PATHW, oldPath, newPath);
Workarounds
- I have tried to notify using the PIDLS, but that didn't update the explorer address bar with the new path
- for long path folders, i have tried sending an UPDATEDIR notification to the parent folder instead of the RENAMEFOLDER notification. This works in that explorer doesn't get put in a bad state, but the user is bounced out of the folder they are viewing in explorer and taken to the parent folder. It's not the end of the world but, not ideal.
Any ideas for alternate approaches for handling this situation?
Thanks!
