Hi,
I have a load .txt button which opens a .txt file into a textarea, and the displays it’s file name in a Listbox row.
The file path is saved in a property “filepath” (type FolderItem).
If I then open a second .txt file, the filepath property obviously changes to the path of this second .txt file.
All ok so far.
The problem is, that when changes are made and it comes to saving back to the same path the .txt file came from - it cannot be saved to filepath, because that is still set to the path of whatever .txt file was opened last.
Well, it looks like you need to store a FolderItem for each text file opened, and not just for the most recent file as you do now. The Listbox would be a good place since you create a new row for each file anyway.
// SET THE FILE’S TEXT CONTENT TO THE ROWTAG
FilesListbox.RowTag(FilesListbox.LastIndex) = tis.ReadAll
// SET THE FILEPATH TO THE CELLTAG
FilesListbox.CellTag(FilesListbox.LastIndex, 0) = f
FilesListbox.ListIndex = FilesListbox.LastIndex[/code]
And here is the line of code for saving a .txt file back to it’s original path:
tos = TextOutputStream.Create(FilesListbox.CellTag(FilesListbox.ListIndex, 0))
The problem now, is that it saves to the file path of the newly selected listbox item, and not to the path for the current item?
It looks like you are using the wrong row index FilesListbox.ListIndex would be the index of the last row added while you must use the index of the currently selected row.
Just forget what I wrote; it was nonsense. Actually your code looks to be correct. Maybe there is something else at work here in other parts of vour code.