|
-
Apr 7th, 2006, 01:08 PM
#1
Thread Starter
-= B u g S l a y e r =-
IO.Directory.Exists and UNC
Hi,
have a problem when running this :
VB Code:
If IO.Directory.Exists("\\192.168.132.151\common\test\") Then
When the ip does not exist on my network the test takes forever and halts my application for 60secs.
I want my application to continue quicker than that.
anyone have any suggestions on how to get around this ?
peet
Last edited by peet; Apr 7th, 2006 at 01:50 PM.
-
Apr 7th, 2006, 01:16 PM
#2
Thread Starter
-= B u g S l a y e r =-
Re: IO.Directory.Exists and UNC
Thanks sevenhalo 
I'll give it a go.
peet
-
Apr 7th, 2006, 01:23 PM
#3
Re: IO.Directory.Exists and UNC
Ummm. Did sevenhalo just delete his post? I just saw it here. Weird.
-
Apr 7th, 2006, 01:24 PM
#4
Re: IO.Directory.Exists and UNC
I did 
I made a mistake, the DNS will resolve it even if it's not an assigned number. My array length validation will always return 1 or more, it'll just take longer if it's not assigned.
I'm looking into this a little further
-
Apr 7th, 2006, 01:25 PM
#5
Thread Starter
-= B u g S l a y e r =-
Re: IO.Directory.Exists and UNC
oh 
in that case dont mind my private message 
peet
-
Apr 7th, 2006, 01:30 PM
#6
Re: IO.Directory.Exists and UNC
 Originally Posted by sevenhalo
I did
I made a mistake, the DNS will resolve it even if it's not an assigned number. My array length validation will always return 1 or more, it'll just take longer if it's not assigned.
I'm looking into this a little further 
I'm glad you caught it. I was about to post almost the same thing.
-
Apr 7th, 2006, 01:33 PM
#7
Re: IO.Directory.Exists and UNC
This seems ok...
VB Code:
Private Function IsRealIP(ByVal strIn As String) As Boolean
'PRE: strIN is an ip in string format
Dim tcp As New System.Net.Sockets.TcpClient
Try
tcp.Connect(System.Net.Dns.GetHostByAddress(System.Net.IPAddress.Parse(strIn)).HostName, 80)
tcp.Close()
Return True
Catch ex As Exception
Return False
End Try
End Function
If this is .Net 05, I'm sure there's some really cool way of doing it, but as far as 1.1 and 03 goes... This is the best I could come up with.
-
Apr 7th, 2006, 01:39 PM
#8
Thread Starter
-= B u g S l a y e r =-
Re: IO.Directory.Exists and UNC
Thanks for taking the time 
Its .net 03, we wont be going for 05 for quite a while yet. Need our 3.rd party components to be 100% before we take the step into the world of fast sexy gui 
peet
-
Apr 7th, 2006, 01:48 PM
#9
Thread Starter
-= B u g S l a y e r =-
Re: IO.Directory.Exists and UNC
VB Code:
If IsRealIP("192.168.132.151") Then
If IO.Directory.Exists("\\192.168.132.151\felles\TMUNA") Then
Dim sr As New IO.StreamWriter("\\192.168.132.151\felles\TMUNA\TmMv2Version.txt")
sr.WriteLine(Application.ProductVersion)
sr.Close()
Else
Debug.WriteLine("Can not write version number to 192.168.132.151!")
End If
End If
wow went from 60 to 6 secs. 
i can live with that 
thanks again.
peet
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
|