Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Knox on Thu 01/07/2010 21:15:32

Title: File.Exists + variable (with String.Format) **SOLVED**
Post by: Knox on Thu 01/07/2010 21:15:32
Hi,

Im sure this is another simple one, I tried to get the right syntax for this but I cant seem to get it to work. I just want to make the file name in the following line to be a variable. I tried String.Format in conjunction with File.Exists + savegame dir without luck.

This works if I name the actual file name (which I dont want, but to debug, it worked)


if (!File.Exists("$SAVEGAMEDIR$/input.bmp"))


This doesnt work, but what I want (make the filename a variable):

if (!File.Exists(String.Format("$SAVEGAMEDIR$/%s.bmp", input))
{
  stuff....
}


Im guessing Im missing a parenthesis somewhere, or I cant use string.format with file.exists?
Title: Re: File.Exists + variable (with String.Format)
Post by: Sslaxx on Thu 01/07/2010 21:19:43
Might it just be something like if (!File.Exists ("$SAVEGAMEDIR$"+input))
{
...
}
instead?

As it is, you're missing a closing parentheses at the end of the "if (!" line anyway.
Title: Re: File.Exists + variable (with String.Format)
Post by: Knox on Thu 01/07/2010 21:23:58

if (!File.Exists(String.Format("$SAVEGAMEDIR$/%s.bmp", input)))


Crap, that works...freakin parenthesis..sesses...

:P