# Directory.GetFiles gets IOException with The network path was not found

• ### Question

• var fileNames = Directory.GetFiles(@"\\spillway\it\ei\lists\repository_xmlschemas1\Attachments", "*.xsd", SearchOption.AllDirectories);

If I run after a boot of Windows 7 I get an IOException with the message 'The network path was not found'. If I first open Windows Explorer to that share then the GetFiles works without error.

How do I establish a connection to that share from within my .NET application?

Thanks,

Tuesday, July 17, 2012 3:56 PM

• WNetAddConnection2  is the way I'm familiar with:

I'm not aware of any managed code way to do this, but here's a p/invoke sample:

Phil Wilson

Tuesday, July 17, 2012 5:48 PM

### All replies

• WNetAddConnection2  is the way I'm familiar with:

I'm not aware of any managed code way to do this, but here's a p/invoke sample:

Phil Wilson

Tuesday, July 17, 2012 5:48 PM
• That worked. Thanks very much for the reply and the pointer to the example.
Tuesday, July 17, 2012 5:58 PM