How can I check if a file exists on the computer by a Visual Basic program?
SB asked:
I want to make a program that checks for a file if that file exists or not. I am adding certain actions that the computer will do if it finds that file but how can i make it check for its existance?
Related posts:
- Really Challenging Visual Basic Question Problem? ABC asked: I have a little problem. I need to...
- computer programming Visual Basic tutorial? John P asked: Can anyone show me how to work...
- How to write a program in Visual Basic to add, update, or delete records? Kevin asked: Okay, I’m about stressed to the limits right...
- Can i write BASIC or VISUAL BASIC programs on the internet? buckbucknumber2000 asked: I’d like to be able to write a...
- Visual Basic Programming Help? Bipul M asked: Does anyone know the code to save...
Filed Under Programming & Design |
Tagged With Checks, Computer Program, Visual Basic Program
Comments
3 Responses to “How can I check if a file exists on the computer by a Visual Basic program?”
Here’s the p-code:
1. Start in the root dir.
2. List all files and dirs in the current dir.
3. If file is present, stop. Otherwise, for each dir previously found, repeat steps 2 and 3.
It’s easy enough to code once you know the logic, and now you know the logic!
Rawlyn.
In classic VB, you can use the Dir() function to do this. Supply the full path and filename as the argument like Dir(”c:\file.txt”) and if it’s there, this will be True; if it isn’t, False.
In VB.NET, use the System.IO.File.Exists (”c:\file.txt”) static (er, Shared) method to do this.
Hi There
Create an instance of the filesystem object
there is a method to check for existance which will return true or false
objFSO.exists(Path)
are you using vbscript or visual basic 6.0 or VB.NET?
cheers
Len