Read/Write Error

squaremation

Active Member
Licensed User
Longtime User
Trying to store some extra data outside the db, and I keep getting this error 'no such file or directory exists' from this code



B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
         If File.Exists(File.DirRootExternal, "User.txt") = True Then
      
                 File.Copy(File.DirInternal, "User.txt", File.DirRootExternal, "User.txt") 'keep getting error 
'on this line have checked the /File and it is included and same spelling and capital
         File.Copy(File.DirInternal, "Level.txt", File.DirRootExternal, "Leveltxt")
         File.Copy(File.DirInternal, "Score.txt", File.DirRootExternal, "Score.txt")
         File.Copy(File.DirInternal, "Cash.txt", File.DirRootExternal, "Cash.txt")
         read
         Else
      
         File.WriteString (File.DirRootExternal, "User.txt","")
         File.WriteString (File.DirRootExternal, "Leveltxt", "")
         File.WriteString (File.DirRootExternal, "Score.txt","")
         File.WriteString (File.DirRootExternal, "Cash.txt","")
   
         'read
      End If
   End If
 

margret

Well-Known Member
Licensed User
Longtime User
You are copying the files from DirInternal but you are not checking to see if they exist in DirInternal. If your files have never been created you are creating them on the External volume not the internal but then you are trying to copy them from the DirInternal volume. Are you sure they have been created in DirInternal. That is not shown in your code.
 
Upvote 0

squaremation

Active Member
Licensed User
Longtime User
resolved

Had to do both of these now it works fine now, after both your answers the process is clear to me. Sorry for cluttering up forum with accidental double post.:confused:

NJDude (to the rescue again)


margret

You are copying the files from DirInternal but you are not checking to see if they exist in DirInternal. If your files have never been created you are creating them on the External volume not the internal but then you are trying to copy them from the DirInternal volume. Are you sure they have been created in DirInternal. That is not shown in your code.
 
Upvote 0
Top