FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


how to check if a file exists. please help (visual basics 6)





andy26
This one has been bugging me alot iv got a program which loads in a .txt file into a text box automaticly when the application starts but there is one problem i have if the .txt is deleted the program wont start so is there a way to include a code into a IF statment so the code will find if the .txt file exists and if it dosent to ignore it or creat the missing file. this would be great help because its really bugging me. thanks in advance.

Edit: iv also found that the visual basics 6 package and deploy dont seem to creat direcotories or if you can please let me know anyway if you can i need some help on some code that can build a new directory such as C:/ program files/myapp/logs. i need this code for when the program is first ime run or it could be at form_load so that when you 1st start the program the new directory is created as i want to store my programs logs in a seperate folder insted of in the app.path directory.
GSIS
That's basic functionality in almost any programming language.

BTW: What language are you using? If we know that we can point you in the right direction.
andy26
O yea so stupid of me not to put the language Visual basic 6.0
Liu
http://www.martin2k.co.uk/vb6/tips/vb_1.php
Trickster
You can also use this method:

If you want to check a file:
Code:
FilePath = App.Path & "\Data\file.txt"

If Len(Dir(FilePath)) Then 'If file exist then.
    'File exist, no code needed.
Else 'If file doesn't exist.
    Open FilePath For Output As #1 'Saves the file.
        'File saved
    Close #1
End If


If you want to check a folder:
Code:
FolderPath = App.Path & "\Data"

If Len(Dir(FolderPath, vbDirectory)) > 0 Then 'If folder exist.
    'Folder exist, no code needed.
Else 'If folder doesn't exist.
    MkDir (FolderPath) 'Creates the folder.
End If
andy26
hey thanks very much its really been buging me.
Related topics
Visual Basic 6
Problem with MySQL Server Please Help!!
Please help regarding editing of index file
Can someone please help me with my website?
URGENT: Please help - site down due to database error
simple php problem, please help...
Help me find please
My sound is mono, please help!
VERY URGENT! Please Help Me!
Please Help Me....
what is wrong with this query? Please please help!
Help! This small script has logical problems. Please help
Amazing Virus! Please Help
I need to increase my monitor pixel please help me
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.