folderitem exist ?

Where is my fault ?
I want to check if the file already exist…

Dim f as FolderItem = SpecialFolder.Preferences.child(file)
if f = Nil then

end if

the file doesn’t exist but “f” is not nil !!!

Thanks in advances


if f.exists

f is not nil, because you can just use f to create a new file.

if f = nil or not f.Exists then ...

This is merely defensive coding, but as Christian noted, f won’t be nil.

Hi kem and Christian,
How can do to known if file exist or not, in order to create it from scratch(textoutputstream) or using the existing previous saved one ?

I think we answered that already: if f.Exists... However, TextOutputStream.Append will do exactly that: It will create the file if it doesn’t exist, or add to it if it does exist.

Thanks kem now I understand, you live in new york? Beautiful city … I live in Milan, Italy.
Thanks again