System.IO.Directory.Exists returns false when directory exists

The following code throws an exception preventing a website from displaying:

        if (!System.IO.Directory.Exists(newPath))
            throw new System.IO.DirectoryNotFoundException();

The newPath variable is a string of the format \\IPADDR\QA\FileAttachments.

The directory can be accessed in either Windows Explorer or Windows PowerShell (running as administrator).

I suspect it is a permissions or security problem, how can I check this?

What are the other possible problems that could generate an fake false?

This code works on another server accessing the exact same folder.

Edit - corrected the string format.

1 answer

  • answered 2018-11-08 14:57 pacmaninbw

    As Dour High Arch pointed out this is probably a duplicate of this question..

    The problem was solved by changing the application pool user to be the administrator of the server.