2

I'm trying to check if a specific image exists in a folder. It is in the solution and the code is returning it to me in the watch.

The code is:

 using SO = System.IO;


  if (SO.File.Exists(Server.MapPath(PathGame)))
            {
                selectJogo.imagemGame = PathGame;
            } 

But it returns false

The watch:

The watch for the variables

EDIT: SO = System.IO

7
  • 4
    File.Exists() might be returning false because the ASP.NET user has no permissions to view it, even though the file does exist
    – paul
    Feb 8, 2013 at 12:50
  • [may be this link could help u.] [1]: stackoverflow.com/questions/10427293/…
    – hungry
    Feb 8, 2013 at 12:54
  • Note that File.Exists never lets you avoid handling all the IOExceptions around file i/o anyway. The file can be created or destroyed between a call to File.Exists and whatever follows it. You must always include the exception handling in your actual use of the file regardless.
    – Greg D
    Feb 8, 2013 at 13:04
  • 1
    What is SO.File? Never heard of such class. The standard .NET class is System.IO.File. Could you show the code of this custom class you are using? Maybe there's a problem with it. Feb 8, 2013 at 14:29
  • Sorry. Missed the 'using SO = System.IO;' on top.
    – dipi evil
    Feb 8, 2013 at 18:36

0

Browse other questions tagged or ask your own question.