Dear All,
I'm trying to check whether file(s) are exist in a folder. Here is my code :

Code:
Private Sub CekFile()
    Dim fName As String
    Dim Th As String
    Dim Bl As String
    Dim Dy As String
    Dim cFile As String
    
    Th = Mid(Year(Date), 4, 1)
    Bl = PadToString(Month(Date), 2)
    Dy = PadToString(Day(Date), 2)
    cFile = "C" & "S" & Th & Bl & Dy & "A.zip"
    
    fName = "c:\data\" & cFile
    
    If Len(Dir$(fName)) <> 0 Then
        MsgBox "File = " & fName & " is exists"
    Else
        MsgBox fName
    End If
End Sub
My question is :

Why does the code always goes to MSGBOX fName ? Even if the file exists...


If got a headache thinking of this. Any help ?

For your information, I got the code from here, VBW.

Thx..
Regards,
Wille