File Rename in VB6



I have the following code in VB6 and I want to change the file extension of all .fin files to .txt. I used the code below to change the extension of all .fin files to .txt. But, the code below is changing the extension of files with no extension as well.

Dim fso As New FileSystemObject
Dim fil As Variant
 
For Each fil In fso.GetFolder(txtsourcedatabase).Files
  If (LCase$(fso.GetExtensionName(fil.Name)) = "fin") Or _
      (fso.GetExtensionName(fil.Name) = vbNullString) Then
    fso.MoveFile fil.Path, fso.BuildPath(fso.GetParentFolderName(fil.Path), _
      fso.GetBaseName(fil.Path) & ".txt")
  End If
Next



This one is simple. Remove the check for NULL from your IF in the code:

Dim fso As New FileSystemObject
Dim fil As Variant
 
For Each fil In fso.GetFolder(txtsourcedatabase).Files
  If (LCase$(fso.GetExtensionName(fil.Name)) = "fin") Then
    fso.MoveFile fil.Path, fso.BuildPath(fso.GetParentFolderName(fil.Path), _
      fso.GetBaseName(fil.Path) & ".txt")
  End If
Next