Mirage Source

Free ORPG making software.
It is currently Fri Mar 29, 2024 3:15 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Check if INI file exists
PostPosted: Wed Jul 08, 2009 8:41 am 
Offline
Pro

Joined: Sat Jun 03, 2006 8:32 pm
Posts: 415
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.

_________________
OREH
http://www.flawsin.com/oreh
Image


Top
 Profile  
 
PostPosted: Wed Jul 08, 2009 12:18 pm 
Offline
Knowledgeable

Joined: Sun Jul 29, 2007 12:23 am
Posts: 199
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


Top
 Profile  
 
PostPosted: Wed Jul 08, 2009 8:58 pm 
Offline
Pro

Joined: Sat Jun 03, 2006 8:32 pm
Posts: 415
thanks much

_________________
OREH
http://www.flawsin.com/oreh
Image


Top
 Profile  
 
PostPosted: Sun Jul 12, 2009 7:20 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Much better function:

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

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group