Rookie
Rookie

Reputation: 8800

How to check if a device is connected to the system or not?

I want to invoke a function only if the device is connected to the system. So my problem is how can I check whether the device is connected or not through USB before invoking the function. Can anyone help...thanks in advance.

Upvotes: 1

Views: 1462

Answers (1)

Yngve B-Nilsen
Yngve B-Nilsen

Reputation: 9676

I think you should be able to find out by using the NetworkInterfaceInfo class:

var typ = NetworkInterface.NetworkInterfaceType;
if(typ == NetworkInterfaceType.Ethernet){
    // do stuff
}

Note: If you disconnect your computer from the internet, I think this is no longer valid.. But as long as you're connected to a computer that is connected to a network and Zune is running, this should work (not tested)

Upvotes: 1

Related Questions