Saving text file to a specific directory

Brian1
02-21-2003, 06:04 PM
I have a program that opens a file for random access. When processing this file sometimes I want to save a copy of the file to a specific directory. How do I do this?


Sub CheckRawData()
Dim Transaction As TransactionNew
Dim FileNum As Integer
Dim RecordLen As Long
Dim Position As Long

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
'SET LINE POSITION AND OPEN RAW FILE
Position = 2
RecordLen = Len(Transaction)
FileNum = FreeFile
Open RawFile For Random As FileNum Len = RecordLen
Get FileNum, Position, Transaction
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
'LOOP THROUGH EACH RECORD AND CHECK FOR ERRORS IN THE DATA
While EOF(FileNum) <> True
Get FileNum, Position, Transaction
Position = Position + 1
testvar = Asc(Transaction.Spacer)
testvar2 = Asc(Transaction.MachineNum)
If Asc(Transaction.MachineNum) = 0 Then
MsgBox "you have reached the end of the file", vbOKOnly
Exit Sub
End If
If Not IsNumeric(Transaction.MachineNum) Then
MsgBox "there is an error in the file", vbOKOnly
FileError = True


'THIS IS WHERE I WANT TO SAVE THE FILE TO A DIRECTORY!!

Exit Sub
End If
Wend
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
End Sub

Squirm
02-21-2003, 06:06 PM
Example:

FileCopy "C:\sourcefile.txt", "C:\backup\destfile.txt"

Brian1
02-21-2003, 06:13 PM
simple enough!:p

thanks

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum