473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Existence of a file

Hi.

How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Thanks
Nov 21 '05 #1
5 1077
It's not too much different than VB 6.

If IO.File.Exists("PathToFile") then
'File Exists - Do whatever you need to do
Else
'File does not exist...
End If

The File Class in the System.IO namespace has a bunch of shared methods
that are very useful. There's also a Directory class in the IO
namespace that you may find useful when dealing with directories and
files. Many of those methods are shared too, so you don't need to
worry about instantiating an instance of the File and/or Directory
classes.

Derek Woo

Nov 21 '05 #2
Add "Imports System.IO" and just use "File.Exists(FileName)"

"Jaime Lucci" wrote:
Hi.

How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Thanks

Nov 21 '05 #3
System.IO.File.Exists()

"Jaime Lucci" <ja********@hotmail.com> wrote in message
news:%2*****************@TK2MSFTNGP15.phx.gbl...
Hi.

How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Thanks

Nov 21 '05 #4
Thanks to everyone.

"Jaime Lucci" <ja********@hotmail.com> wrote in message
news:%2*****************@TK2MSFTNGP15.phx.gbl...
Hi.

How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Thanks

Nov 21 '05 #5
"Jaime Lucci" <ja********@hotmail.com> schrieb:
How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.


Although VB6 didn't have a built-in 'FileExists' command, you can use
'System.IO.File.Exists' or 'System.IO.FileInfo.Exists' instead in VB.NET.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Matt | last post by:
Hello, I see other references in this newsgroup saying that the only standard C++ way to test for file existence is some variant of my code below; can someone please confirm...or offer...
2
by: mike | last post by:
I had a form like below that validated that a file was there before it would submit. <form name="attach" method="POST" action="run_this_pgm.cfm" enctype="multipart/form-data"...
12
by: DC Gringo | last post by:
How do I test for existence of a file in the file system: If FileExists(myVariable & ".pdf") = True pnlMyPanel.Visible = True End If -- _____ DC G
2
by: www.MessageMazes.com | last post by:
Greetings, I'm experimenting with an ASP page that reads data from a file name that is passed to it as a parameter, as in this page, which works, because the "good" file exists. ...
4
by: Eric | last post by:
Is it possible to check for existence of a file from a web page using javascript? I am trying to come up with a routine that i can call from the rest of my javascript code that will check if a...
6
by: Bran Kelly | last post by:
Hi, I am running into something I haven't ever encountered before. I have a static instance of a class declared in a cpp file, which seems to be optimized (or for some other reason) out of...
3
by: trint | last post by:
How can I do this with my c# code with my website(because the file is there, but the code doesn't return it)?: if(File.Exists(String.Format("~/images/categories/{0}", sFileName)) return...
2
by: BobRoyAce | last post by:
I use the following code to check to see if a file exists in a folder: If (_InfeedFilefolder.Length 0) AndAlso (_InfeedFilename.Length > 0) Then If...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.