Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# opening unavailable network path with Process.Start()

I'm opening directories over network using:

System.Diagnostics.Process.Start(path); // path = UNC network path

But having 2 network paths:

\\This_PC_Does_Not_Exist\dir

\\This_PC_Is_Turned_Off\dir

How come first one takes very fast to verify that the network PC doesn't exist, while 2nd takes around two minutes? If I'm not wrong it's 30 seconds in Windows environment to determine if network path is unreachable.

Why does it take so long in this case and how to speed up the info that PC is off?

like image 769
yosh Avatar asked Sep 29 '11 15:09

yosh


1 Answers

In order to load the file, Windows must first make a file sharing connection to the machine. First it looks up the UNC name to get the IP address. If the machine doesn't exist, it can't get an IP address, and it fails quickly (as in the first example). If it does exist (as in the second example), Windows must then attempt to connect.

So why does it take two minutes when the time out is supposed to be 30 seconds? One possibility is that it retries a few times. Another possibility is that you have different network protocols and it has to try each one.

like image 86
Gabe Avatar answered Oct 04 '22 18:10

Gabe