Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if INI file exists
#1
How would I go about this? I know how to check but I dont know everything related to VB yet so I dont know the command I would use. Thanks.

Im finishing up my account creating, checking, logging in so on. Sure my code sucks but works so far lol... might post it soon so people can look over and give me pointers how to optimize it and how im doing it wrong.
Reply
#2
Add this somewhere in a module
Code:
Function FileExist(File As String, FileType As VbFileAttribute) As Boolean
On Error GoTo ErrOut

    If LenB(Dir$(File, FileType)) Then FileExist = True
    Exit Function

ErrOut:

    FileExist = False
    
End Function

Then you can do
Code:
If FileExist(App.Path & "\File.ini", vbNormal) Then

End If

Or.. If it doesnt exist, you can create it like
Code:
If Not FileExist(App.Path & "\File.ini", vbNormal Then

End if
Reply
#3
thanks much
Reply
#4
Much better function:

Code:
Function FileExist(File As String, FileType As VbFileAttribute) As Boolean
    FileExist = LenB(Dir$(File, FileType))
End Function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)