Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: zeroid on June 06, 2015, 12:55:53 AM
-
1. How do i check if the file exist? (in c# File.exist("image.jpg"))
2. How do i get a list of files in that particular folder (directory.getFiles(), returns an array of full filepath)
-
Not sure if there is another way to check if a file exists but you can do:
if ( exists( "myfile") )
{
//file exists
}
function exists( filename )
{
try
{
f = file( "myfile", "r" )
return true;
}
catch ( e )
{
print( "couldn't open file: " + filename + "\n" );
}
return false;
}
For a directory listing, include the file module and use DirectoryListing:
fe.load_module("file");
local dir = DirectoryListing( path );
foreach ( f in dir.results )
{
print( "file: " + f + "\n" );
}
-
Thank you.
could you have a look at my other post?
http://forum.attractmode.org/index.php?topic=227.0 (http://forum.attractmode.org/index.php?topic=227.0)