SHFileOperation - create folder silently

I am using SHFileOperation to move a file.
If the destination folder exists it works fine.
If the destination folder does not exist then it should be created WITHOUT the user confirming.

Using these flags: FOF_NOCONFIRMATION | FOF_SILENT  | FOF_NOERRORUI then it WON'T create the folder.
Using these flags: FOF_NOCONFIRMATION | FOF_SILENT  the I always get the confirmation dialog.

So, what flags do I require for it to create a folder silently?
LVL 45
AndyAinscowFreelance programmer / ConsultantAsked:
Who is Participating?
 
OnegaZhangCommented:
FOF_NOCONFIRMMKDIR

Copy and Move operations can specify destination directories that do not exist and the system will attempt to create them. The system normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags.
0
 
OnegaZhangCommented:
Create the destination folder on your own via
BOOL MakeSureDirectoryPathExists(
  PCSTR DirPath
);

The MakeSureDirectoryPathExists function creates all the directories in the specified DirPath, beginning with the root.

0
 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
Isn't there any set of flags to make the SHFileOperation perform the action silently?  

As I said it will create the directory, it just requests confirmation even when specifying silent operation unless I use the FOF_NOERRORUI and then it fails to create the folder.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
ps. For UNICODE (my case) I would need the SHCreateDirectoryEx function not the MakeSureDirectoryPathExists function
0
 
abithCommented:
I dont know about SHFileOperation ...

But you can achive the same with useing CreateDirectory API.
eg:
      WIN32_FIND_DATA oFindFileData ;
      ZeroMemory(&oFindFileData, sizeof(WIN32_FIND_DATA) );
      HANDLE hRet = FindFirstFile(_T("d:\\t2\\*.*"), &oFindFileData );
      if (hRet == INVALID_HANDLE_VALUE)
      {
            CreateDirectory(_T("d:\\t2"), NULL);
            hRet = (HANDLE) 0 ;
      }
0
 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
Thanks - but to create the folder then the SHCreateDirectoryEx function works perfectly well.

I would like to know what flags one could use with the SHFileOperation to do it silently as part of a move operation.
0
 
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
Excellent - now why didn't I see it in the help file.  (Don't answer).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.