Home All Groups Group Topic Archive Search About
Author
2 Jun 2006 7:06 PM
Mike
Thanks for the reply, I have been trying that, but I keep getting the same
results. The result I get is that the file exits, when it really doesn't.
All my msgbox display twice and I'm not sure why. Here is the code I'm
using. Can you help?

Public Const fnet As String = "\\server1\images"
Public pfile As String = "TEST01.TXT"
Private Sub DoesExist()

        If System.IO.File.Exists(fnet & "\" & pfile) Then

            MessageBox.Show(fnet & "\" & pfile & " file does not exist")
        Else
            MessageBox.Show(fnet & "\" & pfile & " file does exist")
        End If

    End Sub

Author
2 Jun 2006 7:20 PM
Kerry Moorman
Mike,

You have got your messages mixed up. It should be:

        If System.IO.File.Exists(fnet & "\" & pfile) Then

            MessageBox.Show(fnet & "\" & pfile & " file DOES exist")
        Else
            MessageBox.Show(fnet & "\" & pfile & " file does NOT exist")
        End If

Kerry Moorman

Show quoteHide quote
"Mike" wrote:

> Thanks for the reply, I have been trying that, but I keep getting the same
> results. The result I get is that the file exits, when it really doesn't.
> All my msgbox display twice and I'm not sure why. Here is the code I'm
> using. Can you help?
>
> Public Const fnet As String = "\\server1\images"
> Public pfile As String = "TEST01.TXT"
> Private Sub DoesExist()
>
>         If System.IO.File.Exists(fnet & "\" & pfile) Then
>
>             MessageBox.Show(fnet & "\" & pfile & " file does not exist")
>         Else
>             MessageBox.Show(fnet & "\" & pfile & " file does exist")
>         End If
>
>     End Sub
>
>
>
>
Author
2 Jun 2006 10:09 PM
Kevin Westhead
Bear in mind that if File.Exists returns false it doesn't necessarily mean
that the file does not exist; it could mean that the caller has insufficient
permissions to actually test for the existence of the file. If File.Exists
is being used to determine whether or not a file needs to be created, it's
possible for the file creation to fail.

--
Kevin Westhead

Show quoteHide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:4380C96E-448E-43C3-9AFC-7E465AC0092F@microsoft.com...
> Mike,
>
> You have got your messages mixed up. It should be:
>
>        If System.IO.File.Exists(fnet & "\" & pfile) Then
>
>            MessageBox.Show(fnet & "\" & pfile & " file DOES exist")
>        Else
>            MessageBox.Show(fnet & "\" & pfile & " file does NOT exist")
>        End If
Author
5 Jun 2006 8:42 AM
R. MacDonald
Hello, Mike,

Is it possible that you're just suffering a proofreading lapse?  It
looks to me like the code you posted will report the message opposite to
the one you would normally want.

Cheers,
Randy


Mike wrote:
Show quoteHide quote
> Thanks for the reply, I have been trying that, but I keep getting the same
> results. The result I get is that the file exits, when it really doesn't.
> All my msgbox display twice and I'm not sure why. Here is the code I'm
> using. Can you help?
>
> Public Const fnet As String = "\\server1\images"
> Public pfile As String = "TEST01.TXT"
> Private Sub DoesExist()
>
>         If System.IO.File.Exists(fnet & "\" & pfile) Then
>
>             MessageBox.Show(fnet & "\" & pfile & " file does not exist")
>         Else
>             MessageBox.Show(fnet & "\" & pfile & " file does exist")
>         End If
>
>     End Sub
>
>
>