Mirage Source
http://www.miragesource.net/forums/

Check if INI file exists
http://www.miragesource.net/forums/viewtopic.php?f=143&t=5929
Page 1 of 1

Author:  halla [ Wed Jul 08, 2009 8:41 am ]
Post subject:  Check if INI file exists

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.

Author:  Beres [ Wed Jul 08, 2009 12:18 pm ]
Post subject:  Re: Check if INI file exists

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

Author:  halla [ Wed Jul 08, 2009 8:58 pm ]
Post subject:  Re: Check if INI file exists

thanks much

Author:  GIAKEN [ Sun Jul 12, 2009 7:20 pm ]
Post subject:  Re: Check if INI file exists

Much better function:

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/