Announcement

Collapse
No announcement yet.

GetFile

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

  • GetFile

    Have a need to replace this line of code, I'm at work and no more PB at work because I'm on NMCI and it's tightly controlled.
    (In fact they refused my request for PB, they'd rather pay $2500 for VB/DOT-NET Enterprise than do the paperwork to add PB to the DATUMS list.
    (I digress)

    Code:
    If Len(Dir$(RemoteFile,16)) Then Iterate 'it's a directory - do not delete
    With this...


    Code:
    Local FileInfo As WIN32_FILE_ATTRIBUTE_DATA 
    Local fInfoLevelId As GET_FILEEX_INFO_LEVELS  '<---------------- 
    Local lResult As Long
    
    lResult = GetFileAttributesEx(Byval Strptr(FileSpec),fInfoLevelId,FileInfo)
    If FileInfo = %FILE_ATTRIBUTE_DIRECTORY Then Iterate
    because Dir$,16 on UNC paths SEEMS to be returning that all files are "Directories" thus NO files are getting copied over....or deleted (as deemed by this application).

    The application has been rock steady for 4 or 5 years, copying/deleting files based on file/date and time....(Using FindNextFile).....but I have to be absolutely sure I don't delete the Oracle transaction logs (again) - The DBA's started storing the transaction logs in the folder used for User export (Doh).....

    So I have to verify it's NOT a folder...

    Scott Turchin
    Last edited by Scott Turchin; 30 Jan 2009, 12:47 PM.
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    because Dir$,16 on UNC paths SEEMS to be returning that all files are "Directories" thus NO files are getting copied over....or deleted (as deemed by this application).
    That syntax for DIR$ always returns 'regular' files as well as directories.

    Pb/Win 9 / CC5 offers the ONLY keyword to return ONLY directories. (Compiler version in use not shown)

    The application has been rock steady for 4 or 5 years, copying/deleting files based on file/date and time....(Using FindNextFile
    If you are using FindNextFile, then you can just test dwFileAttributes member of the WIN32_FIND_DATA structure returned by same. ...
    Code:
    If ISTRUE (W32.dwAttributes  AND %FILE_ATTRIBUTE_DIRECTORY) THEN 
        it's a directory
    ELSE
        it ain't
    ...
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      if NMCI is what I think it is....then that is why you can not run a good product on a bad machine.....Totally Water-Logged and grunting why?? (but I digress)

      (ok, so I got my ole army shot in....I can really digress now)

      Is the problem from the app showing that DIR is not your current app, but more the current (last folder accessed) outside of your app???
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


      • #4
        Scott,

        You don't identify the loop being Iterated (CNS) so maybe the problem is there.

        If you do not specify DO, LOOP, or FOR, ITERATE will iterate the most recently executed structure. For example:
        FOR ix = 1 TO 10
        DO UNTIL x > 10
        ...
        ITERATE ' will iterate the DO LOOP
        ...
        LOOP
        NEXT
        ITERATE DO and ITERATE LOOP are interchangeable.
        ================================================
        "With malice toward none,
        with charity for all,
        with firmness in the right
        as God gives us to see the right,
        let us strive on to finish the work we are in,
        to bind up the nation's wounds,
        to care for him who shall have borne the battle
        and for his widow and his orphan,
        to do all which may achieve and cherish
        a just and lasting peace among ourselves
        and with all nations."
        Lincoln's Second Inagural Address
        ================================================
        It's a pretty day. I hope you enjoy it.

        Gösta

        JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
        LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

        Comment


        • #5
          Actually NMCI computers are pretty fast - completely functional but VERY strict about what software is "Installed".
          I can "RUN" apps that say, use an INI file with no problem, NoteTab Pro and any software I write - never an issue.


          Anyway OK the code is actually being done in a function and returnign a long string of filenames so the best thing to do is just to remove directories from the list - will try the directory attribute and see what it does for me

          Thanks,


          Code:
          Function CCSGetDirListing(InputDir As String) As String
          Local lCount    As Long
          Local lLoop     As Long
          Local FileSpec  As String
          'Local Extension As String
          Local FileList    As String
          Local f         As Asciiz * %MAX_PATH
          Local FindData    As WIN32_FIND_DATA
          Local hDir        As Long
          
          'ChDir InputDir
          FindData.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY
          f = InputDir & "*.*" 'Read all files, filter later
          hDir = FindFirstFile(f, FindData)
          If hDir = %INVALID_HANDLE_VALUE Then
              Function = "Unale to read directory!"
              Exit Function
          End If
          
          Do
             Select Case Left$(FindData.cFileName,1)
                    Case "." 'Ignore these directories
                    Case "_" 'Front page directories
                    Case Else
                         'Verify the extention is what we are looking for:
                         FileSpec = FindData.cFileName
                         'At this point we have a valid filename
                         Incr lCount
                         If IsTrue Len(FileList) Then
                            FileList = FileList & "|" & FileSpec 'Add Pipe so we can parse on it later
                         Else
                            FileList = FileSpec
                         End If
             End Select
          Loop While FindNextFile(hDir, FindData)
          FindClose hDir
          Function = FileList
          End Function
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            Michael - as usual right on the money save for the AND, I switched to "=" and it worked flawlessly.

            Code:
            Function CCSGetDirListing(InputDir As String) As String
            Local lCount    As Long
            Local lLoop     As Long
            Local FileSpec  As String
            'Local Extension As String
            Local FileList    As String
            Local f         As Asciiz * %MAX_PATH
            Local FindData    As WIN32_FIND_DATA
            Local hDir        As Long
            
            'ChDir InputDir
            FindData.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY
            f = InputDir & "*.*" 'Read all files, filter later
            hDir = FindFirstFile(f, FindData)
            If hDir = %INVALID_HANDLE_VALUE Then
                Function = "Unale to read directory!"
                Exit Function
            End If
            
            Do
                If FindData.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY Then Iterate
                Select Case Left$(FindData.cFileName,1)
                    Case "." 'Ignore these directories
                    Case "_" 'Front page directories
                    Case Else
                         'Verify the extention is what we are looking for:
                         FileSpec = FindData.cFileName
                         'At this point we have a valid filename
                         Incr lCount
                         If IsTrue Len(FileList) Then
                            FileList = FileList & "|" & FileSpec 'Add Pipe so we can parse on it later
                           Else
                              FileList = FileSpec
                           End If
               End Select
            Loop While FindNextFile(hDir, FindData)
            FindClose hDir
            Function = FileList
            End Function
            Scott Turchin
            MCSE, MCP+I
            http://www.tngbbs.com
            ----------------------
            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

            Comment


            • #7
              > save for the AND, I switched to "=" and it worked flawlessly

              ????

              'AND' is the correct operator here: dwFileAttributes member is a set of bit flags.

              Maybe I needed one more or one less set of parens?

              Or maybe you need to
              Code:
              IF (W32.dwFileAttributes AND %FILE_ATTRIBUTE_DIRECTORY ) = %FILE_ATTRIBUTE_DIRECTORY THEN
              I think at some point using "=" you could be in for a rude surprise.

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                OK Gotcha, maybe i copied it wrong...

                I'll check it tonight- looks like they are ordering PBWin now so I won't be doing much with that app anymore...
                Scott Turchin
                MCSE, MCP+I
                http://www.tngbbs.com
                ----------------------
                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                Comment

                Working...
                X