|
-
Apr 2nd, 2002, 09:35 AM
#1
Thread Starter
Addicted Member
problems using WebClient
I made an update system for my app but the only problem is that the thing crashed when ur not connected to the internet. I did some searching on the VB board but all those examples just work for modem/LAN and non works if you have multiple Network cards in ur Comp. Is there something cool in .NET that solves this?
I also tried to use try, catch endtry etc but they don't really help me cause the WebClient comonent just loops until it DLs the file, it's doesn't give up .
-
Apr 2nd, 2002, 10:47 AM
#2
Thread Starter
Addicted Member
yeah but how CAN i detect an internet connection then? I have multiplce network cards and none of the ways shown on the boards seem to work...
-
Apr 2nd, 2002, 02:41 PM
#3
Frenzied Member
use WMI to query the network adapters
This is and example
VB Code:
dim query1 as new ManagementObjectSearcher("select ConnectionState from Win32_NetorkConnection")
dim queryColl as ManagementObjectCollection() = query1.Get()
string connectionState = ""
dim mo as new ManagementObject()
For Each mo In queryColl
connectionState = mo("ConnectionState").ToString()
Next
Select Case connectionState
Case "Connected"
'do whatever
Case "Error"
'do whatever
Case "Paused"
'do whatever
Case "Disconnected"
'do whatever
Case "Connecting"
'do whatever
Case "Reconnecting"
'do whatever
End Select
You have to import System.Management namespace and the System.Managment.dll
Dont gain the world and lose your soul
-
Apr 2nd, 2002, 05:15 PM
#4
Thread Starter
Addicted Member
my .NET doesn;t really like that code, it's full of errors...
-
Apr 2nd, 2002, 05:38 PM
#5
Frenzied Member
Sorry I made a few mistakes, I am so used to the C# syntax, I forgot that I was doing the VB example
Here is updated code without the select statement.
VB Code:
Dim query1 As New ManagementObjectSearcher("select connectionstate from Win32_NetworkConnection")
Dim queryColl As ManagementObjectCollection
queryColl = query1.Get()
Dim connectionState As String = ""
Dim mo As New ManagementObject()
For Each mo In queryColl
connectionState = mo("ConnectionState").ToString()
Next
MessageBox.Show(connectionState)
Last edited by DevGrp; Apr 2nd, 2002 at 05:41 PM.
Dont gain the world and lose your soul
-
Apr 3rd, 2002, 02:01 PM
#6
Thread Starter
Addicted Member
hmmm, the messagebox stays kinda empty....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|