Check if file exists


#1

What’s the best way to determine if a file exists on the controller?


#2

You mean, program-atically, from within your strategy, on the local file system?


#3

Oh, sorry, that would have been helpful information. Yes, programatically, within the strategy on the local file system.


#4

You have a few options here. Simplest/best I’d say: do an [B]Open…[/B] on a “file:” comm handle. (Perhaps followed by a [B]GetNumCharsWaiting [/B]to get the file size, in case a 0 for that means “doesn’t really exist” for you.)

Fancier method if you’re using lots of different files and need a listing, would be to use an “ftp:” comm handle, specifically the “dir” option with [B]SendCommunicationHandleCommand[/B].

BTW, also check out the [B]GetAvailableFileSpace [/B]commandwhich you can use to keep track of how much file space you have remaining in your on-board RAM, flash, or microSD card. Happy “filing”!