How do I write data at the end of a file (size unknown) in binary mode ?
File Write(Append)
Collapse
X
-
Hi,
By default when you open the file, whatever you add will be added after the last character.
Open the file, and a vbCrLF and write the text say:
[code=vb]
Dim FN As Long
i = i + 1
FN = FreeFile
Open "C:\MyText. txt" For Append As FN
Print #FN, vbCrLF & "New Line Added From VB6 Program"
Close #FN
[/code]
First time you have to add vbCrLF, if you want to add few more lines immediately, no need to cancatenate text with vbcrLF...they will be printed in next line..
Regards
VeenaLast edited by Killer42; Nov 5 '07, 01:46 AM. -
Originally posted by aviraldgHow do I write data at the end of a file (size unknown) in binary mode ?
For example...
[CODE=VB]Open "TheFile.xx x" For Binary Access Read Write As #1
Seek #1, Lof(#1)
Put #1,,YourData
[/CODE]
Note: if you want, you can skip the reposition step (the Seek), and specify the position at which to write in the Put statement. (The position is the missing parameter between the commas in the above example.)Last edited by Killer42; Nov 5 '07, 01:54 AM.Comment
Comment