Introduction
Been away for long time so just decided to make a little tutorial about file handling, i'll make it a clear as possible however if it's not clear then just pm me

Background
Little tutorial about file handling
this is something that i did for my course work...In this tutorial i will tell u how to make a small back up program to back up a text document some of you may already know this but hope this will help someone*
lets go step by step!
get ready :
1. open VB
2. New project [don't do anything, yet]
3. Save the project in a folder [make a folder on your desktop name it "backup_program"and save it there for easy access]
4. make a folder there [name it "original"]
5. make another folder [name it "backup]

Screenshot above shows what it should look lyk after you create them folders...
6. rite, now you need a text file in this example i am using "example.txt", thats the file we going to back up]
7. open notepad and type in some random stuff and then save it in the "original" folder.

8. open the VB project you just saved lets get down to making our superb interface!

thats what it should look like!
two command buttons
1
name : cmdCheck
caption : CheckForTheFile
2
name : cmdBackUp
caption : BackupFile
9. now double click on the CheckForFile command button to start coding there are many ways to check if the files there... i am going to use DIR$
so,
first declare a variable
Dim FileCheck as string
and then you can use that variable to check the file availability
basically you telling the program to look in "original" directory for the file called "example.txt"
FileCheck = Dir$("original/example.txt")
and then if the file is not there, FileCheck value will be blank! if it is there then the FileCheck value will be equal to file name... therefore if the file is there the value of FileCheck will be equal to "example.txt"

we could could use that to check if the files present!
to do that we could make a IF statement
Code: VB
if FileCheck = "example.txt" then
msgbox "File Found"
else
msgbox "File Not Found"
end if
Code: VB
if FileCheck <> "" then
msgbox "File Found"
else
msgbox "File Not Found"
end if
now check if it works...
if you get the message box saying "File Found" then your good to go...
...............
now we could get down to coding our second button :BackUpFile: get to the code window
now we know the file is there so we could make the backup now.. here we are using FileCopy method to copy the file to the "backup" directory
simple:
when you type in FileCopy VB will tell you what you have to type in there!
FileCopy "original/example.txt", "backup/exampleBackUp.txt"
right on here we could add date so we know what date that files been backed up all you have to do is put Date$ in middle
FileCopy "original/example.txt", "backup/exampleBackUp" Date$ ".txt"
The code
A brief description of how to use the article or code. The class names, the methods and properties, any tricks or tips.
Blocks of code should be set as style "Formatted" like this.
Code: VB
Private Sub cmdBackUp_Click()
FileCopy "original/example.txt", "backup/example" & Date$ & ".txt"
MsgBox "Backup Complete!!"
End Sub
Private Sub cmdCheck_Click()
Dim FileCheck As String
FileCheck = Dir$("original/example.txt")
If FileCheck <> "" Then
MsgBox "File Found"
Else
MsgBox "File Not Found"
End If
End Sub


there is our backed up file

hope that helped!!!
References
http://www.vbexplorer.com/VBExplorer...00/may2000.asp

