If I copy a file from a special folder to the clipboard, change the location that special folder points to, and try to paste the file to this new location, Windows complains with a Item Not Found error, seemingly trying to copy the file by the filename alone.
The way I change the special folder location is with this line of C++ code:
SHSetKnownFolderPath(FOLDERID_Desktop, 0, NULL, new_location);
And a refresh to see the effect immediately:
SHChangeNotify(0x8000000, 0x1000, NULL, NULL);
Steps to reproduce
-
Desktop pointing to
C:\Users\BoppreH\Desktop -
Copy the file
music 1.mp3from the Desktop (C:\Users\BoppreH\Desktop\music 1.mp3) -
Change location of the Desktop special folder to
D:\music -
The Desktop now shows the musics from
D:\music -
Try to paste
music 1.mp3on the Desktop
It fails with Item Not Found, complaining it could not find the file at D:\music\music 1.mp3, when the file is still happily sitting at C:\Users\BoppreH\Desktop\music 1.mp3. If I paste the file in any other folder that is not the Desktop, it works fine.
I know this is a case of Doctor, it hurts when I do this, and that constantly changing the location of the Desktop is extremely unusual behavior, but this is a feature I’ve grown to love and this bug constantly bites me.
Is there some workaround for this issue?
Use some type of
folder watchercontrol to detect when the Special Folders location has changed and check the clipboard for any file paths that refer to the old location and update them.Or change the location of the Specials before you copy the file.