Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

DirectoryInfo.GetFiles gets System.IO.IOException when file does not exist

$
0
0
We have an application developed in c# that do lots of fileprocessing. This application runs on Windows Server 2008 R2. We have tried both .NET Framework 4.5 and 4.0.
The application runs the following code

cSource String = "\\server1.domain\folder\subfolder";
cFilename String = "NonExistingFile.txt';
DirectoryInfo MyDirectoryInfo = new DirectoryInfo(cSource);
FileInfo[] MyFileInfo = MyDirectoryInfo.GetFiles(cFilename, SearchOption.TopDirectoryOnly);
Server1 is a windows server, We have tested both Windows server 2008 R2 and Windows Server 2003


Our problem is that the last command, MyDirectoryInfo.Getfiles in some circumstances gets an exception when the searched file in sourcefolder do not exist.
When the file exist we never get any problem. The exception is "System.IO.IOException: The specified network name is no longer available"
We have checked fileoperations and file permissions on folders outside the application and we have made the account that runs the application local administrator on the server were we search for files so there is no security issue.

We have figured out the following:
 - If application runs on a server in the same domain as the server in cSource we never get the exception.
 - If application runs on a server in domain1 and search for a file on a server in domain2 we get no exception
 - If application runs on a server in domain2 and search for a file on a server in domain1 we get this exception. We have tested both on 

We run Mcafee as Virus protection on all servers and the Windows firewall is turned off on all servers

Come someone hint us were to troubleshoot this.
Which components/settings can be causing this exception?
Is it the calling applications servers settings that blocks us or is it the server that we read files from that blocks us?

Is it on the server that runs the application?
Or is it on the server were we search for files?

Thanks in advance

/Roger


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>