agraham Expert Licensed User Longtime User Jan 4, 2011 #1 Code: Copy E/B4A (12813*12813): java.lang.UnsupportedOperationException E/B4A (12813*12813): at java.util.AbstractList.remove(AbstractList.java:645) E/B4A (12813*12813): at anywheresoftware.b4a.objects.collections.List.RemoveAt(List.java:93) Code: Copy Dim files As List files = File.ListFiles(IdePath) files.Sort(True) For i = files.Size - 1 To 0 step -1 If File.IsDirectory(IdePath, files.Get(i)) Then Log(files.Get(i)) files.RemoveAt(i) End If Next
Code: Copy E/B4A (12813*12813): java.lang.UnsupportedOperationException E/B4A (12813*12813): at java.util.AbstractList.remove(AbstractList.java:645) E/B4A (12813*12813): at anywheresoftware.b4a.objects.collections.List.RemoveAt(List.java:93) Code: Copy Dim files As List files = File.ListFiles(IdePath) files.Sort(True) For i = files.Size - 1 To 0 step -1 If File.IsDirectory(IdePath, files.Get(i)) Then Log(files.Get(i)) files.RemoveAt(i) End If Next
Erel B4X founder Staff member Licensed User Longtime User Jan 4, 2011 #2 File.ListFiles returns a read-only list. You can't remove items from it. I believe that sorting will also fail (it may seem to work because the files are already sorted).
File.ListFiles returns a read-only list. You can't remove items from it. I believe that sorting will also fail (it may seem to work because the files are already sorted).
agraham Expert Licensed User Longtime User Jan 4, 2011 #3 Thanks Erel, I had totally overlooked that.
Erel B4X founder Staff member Licensed User Longtime User Jan 4, 2011 #4 Note that you can easily copy a list with: Code: Copy Dim List2 As List List2.Initialize List2.AddAll(List1) The new list will not be readonly.
Note that you can easily copy a list with: Code: Copy Dim List2 As List List2.Initialize List2.AddAll(List1) The new list will not be readonly.