Solved

check file exist

Posted on 2006-06-30
2
251 Views
Last Modified: 2012-05-05
Hi,
 How to check if file Exist (VB6) ?

Thanks
0
Comment
Question by:madmare
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("C:\Test.js") Then
  MsgBox "Exists"
End If
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
Comment Utility
Function FileExists(FileName As String) As Boolean
    On Error GoTo ErrorHandler
    ' get the attributes and ensure that it isn't a directory
    FileExists = (GetAttr(FileName) And vbDirectory) = 0
ErrorHandler:
    ' if an error occurs, this function returns False
End Function

 OR another way

 Function FileExist(sTestFile As String) As Boolean
    Dim lSize As Long
    On Error Resume Next
    'Preset length to -1 because files can be zero bytes in length
    lSize = -1
    'Get the length of the file
    lSize = FileLen(sTestFile)
    If lSize > -1 Then
        FileExist = True
    Else
        FileExist = False
    End If
End Function
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now