folderitem is readable problem

Hello, I’m having trouble with a folder item. I have a listbox that gathers the names of files in a folder in the open event and in the change event handler I have the following code:

[code]dim intxt as textinputstream
dim outtxt As TextOutputStream
dim s as string
dim f as FolderItem

f= GetFolderItem(me.Cell(me.ListIndex,0))

intxt=textinputstream.open(f)
s=intxt.readall
[/code]

I am getting an ioexception #2 when I attempt “intxt=textinputstream.open(f)”
It is not clear to me why the files are not readable. Any suggestions?

What are you storing?
The full path or the display name?
What do you get if you test for f.exists first?

check for f=nil first… in case it isn’t even a valid path

What platform? On Windows, error #2 is ERROR_FILE_NOT_FOUND.

Thanks for responding…

Im Running On macos and haven’t tested on the windows machine yet. The files are rtf’s. I can open them with getopenfolderitem so the app knows the files exist. I can msgbox the file name before attempting textinput stream and that works as well. So I don’t think it’s a matter of f.exist even though I haven’t tested for f.exist explicately. I am using the display name to access but the files are in the same folder as the app so I don’t think that’s my problem either.
I’m on mobile device so I hope this message is somewhat intelligible.

I can msgbox the file name before attempting textinput stream and that works as well.<<
You can msgbox the filename of a non-existent file.
A folderitem can refer to a non-existent file: otherwise how would you create one?

I am using the display name to access but the files are in the same folder as the app so I don’t think that’s my problem either. <<

It probably is.
When you fill the listbox, set the row tag property to the actual folder item.
Then when you need to get at the file, use

f= me.Rowtag(me.ListIndex)
if f <> nil and f.exists then

end if

Let me add that f is showing as valid in the debugger and shows as readable = false

Thank you Jeff Tullin, I ended up going with your suggestion (assigning the folderitem to the rowtag).

Out of curiosity, I attempted opening the files from the cell text again only this time using native path and it still doesn’t open because f appears to *not exist

Thanks again!