Check if file exists


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Check if file exists

  1. #1
    John Knoop Guest

    Check if file exists

    Hi!

    Is there a way to determine if a file exists, in VB.NET? I'm not talking
    about the try-and-see-if-I-get-an-error way, nor using the FileSystemObject.

    Is there a built-in function in VB.NET that checks if a file exists?

    /john



  2. #2
    Larry Serflaten Guest

    Re: Check if file exists

    "John Knoop" <john.k@home.se> wrote in message news:3d974b78@10.1.10.29...
    > Hi!
    >
    > Is there a way to determine if a file exists, in VB.NET? I'm not talking
    > about the try-and-see-if-I-get-an-error way, nor using the FileSystemObject.
    >
    > Is there a built-in function in VB.NET that checks if a file exists?
    >
    > /john




    Is there some reason you can't bring up Help and search for an
    Exists property yourself? How about typing System.IO. in the
    editor and using Intellisense to navigate to a few likely suspects?

    Yes, there is a way to tell if a file exists, its in one of the System.IO.
    classes. (Microsoft has taken special care to make these things
    easily discoverable, get used to navigating the heirarchy)

    LFS






  3. #3
    John Knoop Guest

    Re: Check if file exists

    > Is there some reason you can't bring up Help and search for an
    > Exists property yourself?


    Actually there is:
    I do not have VB.NET installed on my computer :-)

    /john

    "Larry Serflaten" <serflaten@usinternet.com> wrote in message
    news:3d978030@10.1.10.29...
    > "John Knoop" <john.k@home.se> wrote in message news:3d974b78@10.1.10.29...
    > > Hi!
    > >
    > > Is there a way to determine if a file exists, in VB.NET? I'm not talking
    > > about the try-and-see-if-I-get-an-error way, nor using the

    FileSystemObject.
    > >
    > > Is there a built-in function in VB.NET that checks if a file exists?
    > >
    > > /john

    >
    >
    >
    > Is there some reason you can't bring up Help and search for an
    > Exists property yourself? How about typing System.IO. in the
    > editor and using Intellisense to navigate to a few likely suspects?
    >
    > Yes, there is a way to tell if a file exists, its in one of the System.IO.
    > classes. (Microsoft has taken special care to make these things
    > easily discoverable, get used to navigating the heirarchy)
    >
    > LFS
    >
    >
    >
    >
    >




  4. #4
    Rune Bivrin Guest

    Re: Check if file exists

    "John Knoop" <john.k@home.se> wrote in news:3d9797a5@10.1.10.29:

    >> Is there some reason you can't bring up Help and search for an
    >> Exists property yourself?

    >
    > Actually there is:
    > I do not have VB.NET installed on my computer :-)
    >
    > /john
    >

    Then try MSDN online. It's all there, y'know.

    --
    Rune Bivrin
    - OOP since 1989
    - SQL Server since 1990
    - VB since 1991


  5. #5
    Miroslav St. Jeliaskoff Guest

    Re: Check if file exists

    System.IO.File.Exists(file) = True / False

    "John Knoop" <john.k@home.se> wrote in message news:3d974b78@10.1.10.29...
    > Hi!
    >
    > Is there a way to determine if a file exists, in VB.NET? I'm not talking
    > about the try-and-see-if-I-get-an-error way, nor using the FileSystemObject.
    >
    > Is there a built-in function in VB.NET that checks if a file exists?
    >
    > /john
    >
    >



  6. #6
    Paul Clement Guest

    Re: Check if file exists

    On Sun, 29 Sep 2002 21:16:39 +0200, "John Knoop" <john.k@home.se> wrote:

    ¤ Hi!
    ¤
    ¤ Is there a way to determine if a file exists, in VB.NET? I'm not talking
    ¤ about the try-and-see-if-I-get-an-error way, nor using the FileSystemObject.
    ¤
    ¤ Is there a built-in function in VB.NET that checks if a file exists?

    You could also search for Dir (Microsoft.VisualBasic.FileSystem namespace) if you still want to use
    the VB Classic functions.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  7. #7
    John Knoop Guest

    Re: Check if file exists

    Ahh! Thanks!


    "Miroslav St. Jeliaskoff" <miroslav@earthling.net> wrote in message
    news:3d98563c@10.1.10.29...
    System.IO.File.Exists(file) = True / False
    "John Knoop" <john.k@home.se> wrote in message news:3d974b78@10.1.10.29...
    > Hi!
    >
    > Is there a way to determine if a file exists, in VB.NET? I'm not talking
    > about the try-and-see-if-I-get-an-error way, nor using the

    FileSystemObject.
    >
    > Is there a built-in function in VB.NET that checks if a file exists?
    >
    > /john
    >
    >




  8. #8
    Join Date
    Feb 2010
    Posts
    1

    Response to questions

    I think it might have been more polite to simple answer the person's question instead of berating them for not looking up elsewhere (they may not know about the "elsewheres".

  9. #9
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    Personnally, I think you should refrain from using anything in Microsoft.VisualBasic (Microsoft.VisualBasic.FileSystem) or its alternative My.Computer.FileSystem.

    These have designed to provide some backward compatibility and help beginners.

    They are very limited compared to what you can find in System.IO.File or System.IO.FileInfo (and Dir, and DirInfo and DriveInfo), and using those, you will not discover what is possible to do with files in .NET.

    And if you ever switch to another .NET language, you will have to learn to use System.IO anyway, so why not do it now while you are working in a language that is easier to learn than most.
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center