Check if File Exists?

Hi,
Is it possible to check to see if a file exists easily?

I would like to check to see if I’ve downloaded a file into tmp:/… and use it if it exists, rather than than just downloading it each time.
-Kevin

    x = MatchFiles("tmp:/",filename)
    if x.Count() = 0 then FILE DOES NOT EXIST

-JT

Or optionally…

fs = CreateObject( "roFileSystem" )
If fs.Exists( "tmp:/myfile") Then
    'found it
End If

Thanks! :slightly_smiling_face:
They both work. Though each one has it’s advantages… I’m using the fs version since I don’t want to parse the filename. :slightly_smiling_face:

I’m starting to collect utility routines that roku is missing… I’ll post them on my website later. Here’s how I tried both styles


Function FileExists(file as String) as Integer
    last = 0
    l = len(file)
    for x = 1 to l
        r = instr(x, file, "/")
        if r > last then last = r
        if r = 0 then exit for
    end for   
    path = left(file, last)
    filename = right(file, l - last)
    return MatchFiles(path, filename).Count()
end function


Function FileExists(file as String) as Integer
    fs = CreateObject("roFileSystem")
    If fs.Exists(file) Then
        return 1
    End If
    return 0
end function