Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It might be a permission issue. From <a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx" rel="nofollow">MSDN</a>, <code>File.Exists(path)</code> returns:</p> <blockquote> <p><strong>true</strong> if the caller has the required permissions and <em>path</em> contains the name of an existing file; otherwise, <strong>false</strong>. This method also returns <strong>false</strong> if <em>path</em> is a null reference (<strong>Nothing</strong> in Visual Basic), an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns <strong>false</strong> regardless of the existence of <em>path</em>.</p> </blockquote> <p><strong>EDIT</strong> Here are two methods that will try to get the ACLs of a directory/file. It's possible that the way that NUnit it being invoked that the permissions are different.</p> <pre><code>Private Shared Function DoesFileExist(ByVal file As String) As Boolean Try Dim FI As New System.IO.FileInfo(file) Dim AC = FI.GetAccessControl() 'This method will fail if the file is not found' Return True Catch ex As System.IO.FileNotFoundException 'FNF error should be thrown if it does not exist' Return False Catch ex As Exception 'If you do not have permission to read the permissions this might throw, too.' 'Of course, in that situation that means that the file exists so we should' 'probably return True here, too. For debugging I am still throwing though.' Throw ex End Try End Function Private Shared Function DoesDirectoryExist(ByVal dir As String) As Boolean Try Dim DI As New System.IO.DirectoryInfo(dir) Dim AC = DI.GetAccessControl() 'This method will fail if the directory is not found' Return True Catch ex As System.IO.DirectoryNotFoundException 'DNF error should be thrown if it does not exist' Return False Catch ex As Exception 'If you do not have permission to read the permissions this might throw, too.' 'Of course, in that situation that means that the directory exists so we should' 'probably return True here, too. For debugging I am still throwing though.' Throw ex End Try End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload