Results 1 to 9 of 9

Thread: IO.Directory.Exists and UNC

  1. #1

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    IO.Directory.Exists and UNC

    Hi,
    have a problem when running this :

    VB Code:
    1. 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.
    -= a peet post =-

  2. #2

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Re: IO.Directory.Exists and UNC

    Thanks sevenhalo

    I'll give it a go.

    peet
    -= a peet post =-

  3. #3
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: IO.Directory.Exists and UNC

    Ummm. Did sevenhalo just delete his post? I just saw it here. Weird.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  4. #4
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    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

  5. #5

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Re: IO.Directory.Exists and UNC

    oh

    in that case dont mind my private message

    peet
    -= a peet post =-

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: IO.Directory.Exists and UNC

    Quote 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.

  7. #7
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: IO.Directory.Exists and UNC

    This seems ok...
    VB Code:
    1. Private Function IsRealIP(ByVal strIn As String) As Boolean
    2.         'PRE:  strIN is an ip in string format
    3.  
    4.         Dim tcp As New System.Net.Sockets.TcpClient
    5.  
    6.         Try
    7.             tcp.Connect(System.Net.Dns.GetHostByAddress(System.Net.IPAddress.Parse(strIn)).HostName, 80)
    8.             tcp.Close()
    9.             Return True
    10.         Catch ex As Exception
    11.             Return False
    12.         End Try
    13.     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.

  8. #8

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    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
    -= a peet post =-

  9. #9

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Re: IO.Directory.Exists and UNC

    VB Code:
    1. If IsRealIP("192.168.132.151") Then
    2.             If IO.Directory.Exists("\\192.168.132.151\felles\TMUNA") Then
    3.                 Dim sr As New IO.StreamWriter("\\192.168.132.151\felles\TMUNA\TmMv2Version.txt")
    4.                 sr.WriteLine(Application.ProductVersion)
    5.                 sr.Close()
    6.             Else
    7.                 Debug.WriteLine("Can not write version number to 192.168.132.151!")
    8.             End If
    9.         End If

    wow went from 60 to 6 secs.

    i can live with that

    thanks again.

    peet
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width