Site hosted by Angelfire.com: Build your free website today!

∆  Advertisements

   TrueLogic

  Softwares

TrueLogic Software

Home  Articles  Products  Support  Feed Back  NewsLetter  Site Map  ABOUT US

How to Know that the Specified File Exists, without using FileSysytemObject in VB6 :

Author : Lalit K Chaudhary
E-mail : Lalit_9876@yahoo.com

Knowledge of Visual Basic 6.0 is Enough to Understand this Article.
Level of Difficulty 1 2 3 4 5

 

Source Code for this Article None  

Many times it is Necessary to Know Programmatically that the Specified File is Exist in Local Hard Drive, Although it Can be Easily Achieved through FileSystemObject in VB, But it will Add a Large Dependency to your Project.

Think of a Situation where you are not using FileSystemObject Widely in your Project, then this dependency will become major overhead to you.

I have Developed a Simple Function that will do this job, without adding any dependency to your project, because it used Simple VB functions.

Ö Source Code : IsFileExist.Bas
Public Function IsFileExist(ByVal File As String) As Boolean
Dim
Sret As String
Dim
FTitle As String

FTitle = Mid(File, InStrRev(File, "\") + 1)
'Return Only File Name
Sret = Dir(File, vbNormal + vbReadOnly + vbHidden + vbArchive + vbSystem)

If
LCase(Sret) = LCase(FTitle) Then
 IsFileExist =
True
Else

 IsFileExist =
False
End
If
End
Function

The Function is Straight Forward. Argument should be in Full file Path format e.g. "C:\Windows\App.txt" this function will first Extract Actual filename e.g. App.txt, then using Dir function it will check that the file is there or not, and Return the respective Value to the caller.

Copyright © 2005 Lalit K Chaudhary
All the Applications and Codes are Authorized to Owner.
You can use it, Distribute it But U can't Modify or Take Credit of It, To Get full Info See
License
Contact At:
Lalit_9876@yahoo.com  or Truelogic@Truelogic.cjb.Net
True       Logic Softwares is Dedicated to Change Your Life's Logic...

Last updated : Sunday ,October 30, 2005