Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 24th, 2004, 12:47 PM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to check whether a filie is existing

Well I am tying to open a file for reading which does not exist and thus getting an erro message. How to check whether a file is existing before I open it for reading?

I am using VB.NET and doing windows application :)
 
Old November 24th, 2004, 01:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

im using this to know it: System.IO.File.Exists



HTH

Gonzalo
 
Old December 6th, 2004, 03:49 PM
Authorized User
 
Join Date: Oct 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could also try:

Dim objReader As StreamReader
Try
objReader = New StreamReader(FileName)
Catch i As System.IO.FileNotFoundException
    msgbox("File not found")
End Try





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect to VSS check-in Check-out Programatically rhd110 General .NET 6 August 12th, 2007 07:46 AM
Check For Existing Folders & Files zandermax Access VBA 2 September 30th, 2005 11:43 AM
Adding existing and non-existing attributes spencer.clark XSLT 5 July 27th, 2005 04:02 PM
check for existing records b4 insertion deian Access ASP 11 June 13th, 2004 09:01 AM
Check for existing record echajmovic Access 1 November 3rd, 2003 08:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.