Mirage Source
Check if INI file exists - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Programming (https://mirage-engine.uk/forums/forumdisplay.php?fid=24)
+----- Forum: Visual Basic 6 (https://mirage-engine.uk/forums/forumdisplay.php?fid=32)
+----- Thread: Check if INI file exists (/showthread.php?tid=2920)



Check if INI file exists - halla - 08-07-2009

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.


Re: Check if INI file exists - Beres - 08-07-2009

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



Re: Check if INI file exists - halla - 08-07-2009

thanks much


Re: Check if INI file exists - GIAKEN - 12-07-2009

Much better function:

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