Trying to check a file's existence

This is driving me nuts. I’ve been merrily loading in content with the Monogame Pipeline Tool, but I’ve got to the stage where I need to check if a file is present.

I’ve been using file paths in the format of @"folder\subfolder\fileToLoad" without issue, but I can’t get that format to work with File.Exists(). I have thus had to resort to doing this:


I don’t like having to specify the Content folder, as well as the xnb file extension. Is there no way to check for a file’s existence using the @ format?

Maybe not the answer you’re looking for, but you could create a method to does it for you

public static bool Exists(string path)
  return File.Exists($@"Content\{path}.xnb")

Sorry if I’m missing the point

Thanks for the reply. That would certainly work. I just wondered if there was something I was missing.

Is there a reason why you need to check if the file exists in the first place?

Yes, I’m reading in a file containing all the written dialogue for my game. Each line is parsed and if a corresponding audio file can be found, then audio plays when the text is displayed. So not every written line will have a corresponding audio file, hence me checking.