Announcement

Collapse
No announcement yet.

Name of the Win API that copies a file and creates the directory if is is not there.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Name of the Win API that copies a file and creates the directory if is is not there.

    It is something like CopyFileBeSureDirectoryExists...

  • #2
    I found it MakeSureDirectoryPathExists function.

    Comment


    • #3
      David,
      But that's not what you asked for. There's no file copy in the API.

      Also, I checked Jose's includes and did not see the API. You'll have to custom make the declaration. The header file was given as dbghelp.h and the DLL was dbghelp.dll.

      I don't see that DLL anywhere on my Win10 system ... wait ... yep I do see it in Visual Studio and MS Office folders.

      ... added ... subsequently found the declaration in Jose's help. Not sure how I missed it the first time.
      Last edited by Gary Beene; 7 Feb 2019, 11:10 PM.

      Comment


      • #4
        Dave,
        In case you don't want the API, here something I just whipped up. Works for me.

        Code:
        MakePathExist "c:\tempz\a\b\c"  'no \ on end
        
        Sub MakePathExist(fullpath$)
           Local i As Long, temp$
           temp$ = Parse$(fullPath$,"\",1) 'assumes fullpath$ has drive letter
           For i = 2 To ParseCount(fullpath$,"\")
              temp$ += "\" + Parse$(fullPath$,"\",i)
              If IsFalse IsFolder(temp$) Then MkDir temp$
           Next i
        End Sub

        Comment


        • #5
          BTW

          MakeSureDirectoryPathExists() is exported by both imagehlp.dll and dbghlp.dll

          Jose's includes ImageHlp.inc and DbgHelp.inc have declarations for MakeSureDirectoryPathExists.
          Code:
          DECLARE FUNCTION MakeSureDirectoryPathExists LIB "IMAGEHLP.DLL" ALIAS _
                          "MakeSureDirectoryPathExists"(lpDirName AS ASCIIZ) AS LONG
          "This function does not support Unicode strings. To specify a Unicode path, use the SHCreateDirectoryEx function".
          Rgds, Dave

          Comment


          • #6
            Name of a Win API that copies a file and creates the directory if is is not there: shFileOperation

            Comment


            • #7
              Originally posted by Pierre Bellisle View Post
              Name of a Win API that copies a file and creates the directory if is is not there: shFileOperation
              https://docs.microsoft.com/en-us/win...fileoperationa

              This function has been replaced in Windows Vista by IFileOperation.

              https://docs.microsoft.com/en-us/win...ifileoperation

              This interface replaces the SHFileOperation function.

              Comment


              • #8
                Yep,
                I know that, but the question was, let's say, more about an API than an interface.
                For many shFileOperation will be easier to use.
                shFileOperation works pretty fine with Windows Seven... Windows Ten.
                And it will work for a real long time due to Microsoft policy to keep genuine stuff
                working to avoid breaking so much code in the field.

                Here is a great example from Bob Houle: Using Shell32 as XCOPY

                Comment


                • #9
                  Thanks everybody! Very helpful!

                  Comment

                  Working...
                  X