rossati Active Member Licensed User Longtime User Jul 9, 2012 #1 Hello I try to add an item to a list, but java get the unsupportedoperationexception error: Sub insertlistDir(dir As String) As List Dim lst As List lst = File.ListFiles(dir) lst.SortCaseInsensitive(True) 'If dir.indexOf2("/",1) > -1 Then lst.InsertAt(0,"..") lst.add("..") Return lst End Sub Click to expand... ... //BA.debugLineNum = 286;BA.debugLine="lst.add(\"..\")"; _lst.Add((Object)("..")); ... Click to expand... what is wrong? John Rossati
Hello I try to add an item to a list, but java get the unsupportedoperationexception error: Sub insertlistDir(dir As String) As List Dim lst As List lst = File.ListFiles(dir) lst.SortCaseInsensitive(True) 'If dir.indexOf2("/",1) > -1 Then lst.InsertAt(0,"..") lst.add("..") Return lst End Sub Click to expand... ... //BA.debugLineNum = 286;BA.debugLine="lst.add(\"..\")"; _lst.Add((Object)("..")); ... Click to expand... what is wrong? John Rossati
S spillo3d96 Member Licensed User Longtime User Jul 9, 2012 #2 First you have to initialize your list : Lst.Initialize And then to add an item: Lst.AddSingleLine("Item #" & i) or Lst.Add() Last edited: Jul 9, 2012 Upvote 0
First you have to initialize your list : Lst.Initialize And then to add an item: Lst.AddSingleLine("Item #" & i) or Lst.Add()
mc73 Well-Known Member Licensed User Longtime User Jul 9, 2012 #3 I've read that file.listfiles returns a read-only list. perhaps this is causing the error. could you try capitalizing a new list and copy the contents of the previous one? maybe it works. Update: Try this: Code: Copy Dim lst As List lst.Initialize lst.AddAll (File.ListFiles(dir)) lst.SortCaseInsensitive(True) 'If dir.indexOf2("/",1) > -1 Then lst.InsertAt(0,"..") lst.add("..") Return lst Last edited: Jul 9, 2012 Upvote 0
I've read that file.listfiles returns a read-only list. perhaps this is causing the error. could you try capitalizing a new list and copy the contents of the previous one? maybe it works. Update: Try this: Code: Copy Dim lst As List lst.Initialize lst.AddAll (File.ListFiles(dir)) lst.SortCaseInsensitive(True) 'If dir.indexOf2("/",1) > -1 Then lst.InsertAt(0,"..") lst.add("..") Return lst
rossati Active Member Licensed User Longtime User Jul 9, 2012 #4 Thanks to all it is solved, the first error is the list must be initialised, the second is I can't manipulate a read only list wich seems is the case of File.ListFiles. John Rossati Upvote 0
Thanks to all it is solved, the first error is the list must be initialised, the second is I can't manipulate a read only list wich seems is the case of File.ListFiles. John Rossati