A corporate customer had a problem with their employees accidentally deleting folders like Videos and Pictures and are looking for a way to restore them, short of blowing away the entire user profile and starting over. They found some techniques on the Internet but they don’t always work consistently or completely. What is the recommended way of recreating these missing folders?
It turns out that the customer was asking a question that I answered many years ago, but looking at it from the other side.
To recreate a folder, call SHGetFolderPath
with the flag CSIDL_FLAG_CREATE
, or call SHGetSpecialFolderPath
and pass fCreate = TRUE
.
If you are targeting Windows Vista or higher, the known-folder equivalent is calling SHGetKnownFolderPath
, SHGetKnownFolderIDList
, or SHGetKnownFolderItem
with the KF_FLAG_CREATE
flag.
(There is a CSIDL
-to-KF conversion table in MSDN.)
0 comments