File.Exists + variable (with String.Format) **SOLVED**

Started by Knox, Thu 01/07/2010 21:15:32

Previous topic - Next topic

Knox

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)

Code: ags

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


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

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?
--All that is necessary for evil to triumph is for good men to do nothing.

Sslaxx

Might it just be something like
Code: ags
if (!File.Exists ("$SAVEGAMEDIR$"+input))
{
...
}
instead?

As it is, you're missing a closing parentheses at the end of the "if (!" line anyway.
Stuart "Sslaxx" Moore.

Knox

Code: ags

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


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

:P
--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk