vb1992 Well-Known Member Licensed User Longtime User Jan 5, 2012 #1 I was deleting files with B4a today, and the following command didn't remove the file? It did find the file with Exists I checked the manifest file and it does have: Code: Copy <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> SplitDir = "/mnt/sdcard" SplitFile = "test.txt" Code: Copy If File.Exists(SplitDir,SplitFile) Then Msgbox("File Is being Deleted now!","DELETED") File.Delete(SplitDir,SplitFile) Else Msgbox("Can't find file!","NOPE") End If I ended up using this and it worked: Code: Copy If File.Exists(SplitDir,SplitFile) Then Msgbox("File Is being Deleted now!","DELETED") Dim sb As StringBuilder sb.Initialize p.Shell("rm -r " & SplitDir & "/" & SplitFile , Null, sb, Null) ' free space Else Msgbox("Can't find file!","NOPE") End If I am more curious why the first snippet didn't work?
I was deleting files with B4a today, and the following command didn't remove the file? It did find the file with Exists I checked the manifest file and it does have: Code: Copy <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> SplitDir = "/mnt/sdcard" SplitFile = "test.txt" Code: Copy If File.Exists(SplitDir,SplitFile) Then Msgbox("File Is being Deleted now!","DELETED") File.Delete(SplitDir,SplitFile) Else Msgbox("Can't find file!","NOPE") End If I ended up using this and it worked: Code: Copy If File.Exists(SplitDir,SplitFile) Then Msgbox("File Is being Deleted now!","DELETED") Dim sb As StringBuilder sb.Initialize p.Shell("rm -r " & SplitDir & "/" & SplitFile , Null, sb, Null) ' free space Else Msgbox("Can't find file!","NOPE") End If I am more curious why the first snippet didn't work?
NJDude Expert Licensed User Longtime User Jan 5, 2012 #2 I think you need to: Code: Copy SplitDir = "/mnt/sdcard" 'No SplitDir = "/mnt/sdcard/" 'Yes Add a "/", you are doing it on the code that worked. Upvote 0
I think you need to: Code: Copy SplitDir = "/mnt/sdcard" 'No SplitDir = "/mnt/sdcard/" 'Yes Add a "/", you are doing it on the code that worked.