Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
YungBlood
Streaming Star

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
YungBlood

Bringing more fun to Roku!
0 Kudos
3 REPLIES 3
renojim
Community Streaming Expert

Re: Check if File Exists?

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


-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
TheEndless
Channel Surfer

Re: Check if File Exists?

Or optionally...
fs = CreateObject( "roFileSystem" )
If fs.Exists( "tmp:/myfile") Then
'found it
End If
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
YungBlood
Streaming Star

Re: Check if File Exists?

Thanks! 🙂
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. 🙂

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
YungBlood

Bringing more fun to Roku!
0 Kudos