Announcement

Collapse
No announcement yet.

Error 70 - ?entire subfolder structure affected.

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

  • Error 70 - ?entire subfolder structure affected.

    A shared folder on a reasonably large network running my .EXE has the following directory/folders:
    S:\MINDEXii.DAT
    S:\MINDEXii.DAT\LOGS
    S:\MINDEXii.DAT\LOGS\620001
    S:\MINDEXii.DAT\LOGS\620002
    ​S:\MINDEXii.DAT\LOGS\620003

    The top-level folder S:\MINDEXii.DAT contains .DAT files frequently accessed by multiple workstations.

    The individual sub-folders eg: S:\MINDEXii.DAT\LOGS\620001 are only each accessed by one workstation (named 620001 thru 629999).

    Here's the query: when the top-level folder .DAT files in S:\MINDEXii.DAT are being accessed, all sub-folders appear to be locked and concurrently trying to access eg: S:\MINDEXii.DAT\LOGS\620001 returns error 70. Is the file or the entire folder that gets locked? It appears to be the top-level folder and every sub-folder below that.

    Not a problem on XP-Pro or W7 - only a problem with W10 - consistently over many W10 workstations.






  • #2
    The first thing that strikes me is the dot in the folder name. While not illegal, it may be causing issues somewhere with WIn10's handling of locking.
    Also, is the file server runnng Windows (if so, what version) or some *nix variant?


    Added: Note that dots are not valid in Azure Share names - so maybe MS have done something in WIn10/11 to deal with that and that has messed things up.

    Comment


    • #3
      Using different file channels get no error, but there are no other users.
      Only thing I can think of is to write a little test program and keep expanding on it.
      Possibly a missing SHARED clause, a missing UNLOCK or using wrong channel?

      Possibly not using ERRCLEAR in a network environment before attempting to open a locked file in a loop.

      Only problem with Win 10, maybe a file locked out by virus checker? That is strange.
      Might check the read/write permissions of each folder. Change to Everyone and mark all.

      Code:
      FUNCTION PBMAIN AS LONG
      
       LOCAL s1,s2 AS STRING
      
       MKDIR "\mindexii.dat"
       MKDIR "\mindexii.dat\logs"
       MKDIR "\mindexii.dat\logs\620001"
       
       ERRCLEAR
       OPEN "\mindexii.dat\test.dat" FOR BINARY AS #1
       IF ERR THEN ? "Open error":EXIT FUNCTION
       s1 = TIME$
       PUT #1,1,s1
       IF ERR THEN ? "put error":EXIT FUNCTION
       GET #1,1,s1
       IF ERR THEN ? "get error":EXIT FUNCTION
      
       OPEN "\mindexii.dat\logs\620001\test.dat" FOR BINARY AS #2
       IF ERR THEN ? "Open error":EXIT FUNCTION
       s2 = TIME$
       PUT #2,1,s2
       IF ERR THEN ? "put error":EXIT FUNCTION
       GET #2,1,s2
       IF ERR THEN ? "get error":EXIT FUNCTION
      
       ? USING$("&&&",s1,$CRLF,s2),,"No error"
      
      END FUNCTION
      The world is full of apathy, but who cares?

      Comment


      • #4
        >Is the file or the entire folder that gets locked?
        Should only be the file in your open statement or lock statement.

        Code:
        'Lock a file at top level while writing to $LogFile.  Tested on Windows 10/11.
        'Create directory structure using MakeSureDirectoryPathExists (thanks Stuart)
        'If this doesn't run on your system then this can be used to find the error.  Modify h drive.
        
        #DIM ALL
        $LogFile = "h:\mindexii.dat\logs\620001\log.txt"
        #INCLUDE "win32api.inc"
        GLOBAL gcs AS CRITICAL_SECTION
        DECLARE FUNCTION MakeSureDirectoryPathExists LIB "IMAGEHLP.DLL" ALIAS "MakeSureDirectoryPathExists" (DirPath AS ASCIIZ) AS LONG
        
        FUNCTION SystemErrorMessageText (BYVAL ECode AS LONG) AS STRING
          LOCAL Buffer AS ASCIIZ * 255
          FormatMessage %FORMAT_MESSAGE_FROM_SYSTEM, BYVAL %NULL, ECode, %NULL, buffer, SIZEOF(buffer), BYVAL %NULL
          FUNCTION = FORMAT$(ECode, "#####") & Buffer
        END FUNCTION
        
        FUNCTION PBMAIN AS LONG
        
         LOCAL users,result,e,threadnum,hthread,h,linecounter AS LONG
         LOCAL sdirectory AS STRING
        
         InitializeCriticalSection gcs
        
         users = 3 'thread for each user
        
         sdirectory = "h:\mindexii.dat\logs\620001\"             'the string must end with a backslash
         result = MakesureDirectoryPathExists(BYCOPY sdirectory)
         IF result = 0 THEN
          e = GetLastError:? sdirectory + $CR + SystemErrorMessageText(e),%MB_ICONERROR,"ERROR: Could NOT create folder"
          EXIT FUNCTION
         END IF
        
         OPEN "h:\mindexii.dat" FOR OUTPUT AS #1  'lock a file at top level
        
         FOR threadnum = 1 TO users
          THREAD CREATE LogThread(threadnum) TO hThread
          SLEEP 1
          THREAD CLOSE hThread TO hThread
         NEXT
         DO
          SLEEP 50
         LOOP UNTIL THREADCOUNT = 1
        
        deletecriticalsection gcs
         h = FREEFILE 'optionally verify log
         OPEN $Logfile FOR INPUT AS #h
         FILESCAN #h, RECORDS TO linecounter
         REDIM TheData(1 TO linecounter) AS STRING
         LINE INPUT #h, TheData() TO linecounter
         CLOSE #h
         ? JOIN$(TheData(),$CRLF)
        END FUNCTION
        
        THREAD FUNCTION LogThread(BYVAL threadnum AS LONG) AS LONG
         LOCAL h,attempt AS LONG
         EnterCriticalSection gcs
         h = FREEFILE
         FOR attempt = 1 TO 10
          OPEN $Logfile FOR APPEND AS #h 'exclusive lock
          IF ERR = 0 THEN EXIT FOR
          SLEEP 100
         NEXT
         IF ERR THEN
          ? "Could not open logfile in thread" + STR$(threadnum),,"ERR"+STR$(ERR)
         ELSE
          PRINT #h, USING$("&:&",TIME$,"Hello from thread"+STR$(threadnum))
         END IF
         CLOSE h
         LeaveCriticalSection gcs
        END FUNCTION
        The world is full of apathy, but who cares?

        Comment


        • #5
          Owen, are you saying that if you open a file like S:\MINDEXii.DAT\MyFile.txt with PB, files like S:\MINDEXii.DAT\LOGS\620001\TheirFile.txt are being locked?

          Added: Windows is 100% fine with dots (even multiple dots) in file and folder names, but, of course it can confuse software that assumes that the only dot is the file extension.
          "Not my circus, not my monkeys."

          Comment


          • #6
            My imagination, or
            ????
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Originally posted by Eric Pearson View Post
              Owen, are you saying that if you open a file like S:\MINDEXii.DAT\MyFile.txt with PB, files like S:\MINDEXii.DAT\LOGS\620001\TheirFile.txt are being locked?

              Added: Windows is 100% fine with dots (even multiple dots) in file and folder names, but, of course it can confuse software that assumes that the only dot is the file extension.
              Is it a OneDrive or Sharepoint?

              This article contains information about the restrictions and limitations that apply to files, file names and file types when syncing with OneDrive for home, OneDrive for work or school or SharePoint in Microsoft 365.

              Characters that aren't allowed in file and folder names in OneDrive for work or school
              ~ " # % & * : < > ? / \ { | }.​

              Comment


              • #8
                Originally posted by Stuart McLachlan View Post
                Is it a OneDrive or Sharepoint?
                No. Although I have no control over the servers, I believe they are Windows 2022 servers.


                Comment


                • #9
                  Owen, are you saying that if you open a file like S:\MINDEXii.DAT\MyFile.txt with PB, files like S:\MINDEXii.DAT\LOGS\620001\TheirFile.txt are being locked?

                  Added: Windows is 100% fine with dots (even multiple dots) in file and folder names, but, of course it can confuse software that assumes that the only dot is the file extension.​
                  Correct, only one file appears readable at a time at any level within S:\MINDEXii.DAT\. I am circumnavigating the issue by trapping error 70 and trying again, ultimately this works but the endless error 70's need to be resolved.

                  Comment


                  • #10
                    Is the open statement mode shared?
                    Is the file closed after each usage?
                    The world is full of apathy, but who cares?

                    Comment


                    • #11
                      Originally posted by Mike Doty View Post
                      Is the open statement mode shared?
                      Is the file closed after each usage?
                      Yes and yes.
                      The issue is that other users are properly accessing one file within the folder yet all files in the folder (and below) then return 70 until the other user/s have done. In other words, the entire folder is being locked by a simple rw.

                      Comment


                      • #12
                        How can I find out which process is locking a file or folder in Windows? For instance, when trying to delete a folder, Windows reports this: The action can't be completed because the folder is ...


                        Is Advanced security settings set to full control?
                        Does the owner of the account exist?
                        The world is full of apathy, but who cares?

                        Comment


                        • #13
                          Originally posted by Owen English View Post
                          No. Although I have no control over the servers, I believe they are Windows 2022 servers.
                          Sounds like an issue that should be taken up with the server administrators. I doubt that its a PB issue at all.
                          At least they will be able to see what is going on and why the locks are being applied.

                          Comment


                          • #14
                            What software is creating/maintaining the .dat files? Is it managing them in real time?
                            "Not my circus, not my monkeys."

                            Comment


                            • #15
                              While the dot is legal, it makes everything to the right look like file extension if parsing the path from the right.
                              Code:
                              INSTR(-1, str, ".")
                              then
                              INSTR(-x, str, "\") 'next character start of file name
                              INSTR(-y, str, "\") 'next character start of lowest folder name
                              ((examples in post 1 do not have extensions, making dot in folder name the first dot from the right))
                              Is code, not shown, "opening"/locking a whole folder as one file?

                              May be old fashioned, but I still use underscores in paths instead of spaces too.


                              Cheers,
                              Last edited by Dale Yarker; 7 May 2023, 03:58 AM. Reason: ​​​​​​​((added code tags because back slashes disappeared))
                              Dale

                              Comment


                              • #16
                                Originally posted by Dale Yarker View Post
                                May be old fashioned, but I still use underscores in paths instead of spaces too.
                                Me too. EIther that of CamelCase. Preferably the latter

                                Comment


                                • #17
                                  Verified PATHNAME$ has no problem with dot in filespec.
                                  Code:
                                  FUNCTION PBMAIN AS LONG
                                    LOCAL sfilespec       AS STRING
                                    REDIM sResult(1 TO 5) AS STRING
                                    sfilespec = "S:\MINDEXii.DAT\MyFile.txt"
                                    sResult(1)=PATHNAME$(FULL,sfilespec) 'S:\MINDEXii.DAT\MyFile.txt
                                    sResult(2)=PATHNAME$(PATH,sfilespec) 'S:\MINDEXii.DAT\
                                    sResult(3)=PATHNAME$(NAME,sfilespec) 'MyFile
                                    sResult(4)=PATHNAME$(EXTN,sfilespec) '.txt
                                    sResult(5)=PATHNAME$(NAMEX,sfilespec)'MyFile.txt
                                    ? JOIN$(sResult(),$CRLF)
                                  END FUNCTION


                                  >No. Although I have no control over the servers, I believe they are Windows 2022 servers.
                                  Originally posted by Stuart McLachlan View Post
                                  Sounds like an issue that should be taken up with the server administrators. I doubt that its a PB issue at all.
                                  At least they will be able to see what is going on and why the locks are being applied.
                                  The world is full of apathy, but who cares?

                                  Comment


                                  • #18
                                    1. Your example path contains two dots.

                                    2. We still do not know what Owen is doing (in code).
                                    Dale

                                    Comment


                                    • #19
                                      1. ​PathName$(Full,filespec$) also returns the filename which includes the second dot. ' S:\MINDEXii.DAT\MyFile.txt
                                      2. True
                                      The world is full of apathy, but who cares?

                                      Comment


                                      • #20
                                        Does it get confused when there is no file name extension? (the point of bringing it up before) As 2. is true and we don't know if Owen used PATHNAME$, it is "a shot in the dark". We don't even know if there is another program between Owen's failing code and the server OS.
                                        Dale

                                        Comment

                                        Working...
                                        X