Working with files.

M

Morris

Hi, Ive got two questions:

1) How can I open a txt file on the hard drive to append it.
2) How can I write a trext to a file bypassing system's buffering - so
that it;s instantly saved to a file?


Cheers
 
D

Douglas J. Steele

<picky>

While Roger's answer to question 1 is correct, be aware that you should
never hard-code the file handle as his sample does.

Instead, you should use the FreeFile function to determine an appropriate
file handle:

Dim intFile As Integer

intFile = FreeFile()
Open "C:\Myfile.txt" For Append As #intFile

</picky>
 
R

Roger Carlson

Oh, I think "never" is too strong. I agree that if you are doing extensive
low-level file I/O, you are opening multiple files, or the same file
multiple times ( as with Binary, Input, or Random modes), that is best
practice. However, it is perfectly acceptable to use a hard-coded number
for one-off file access.

At least, I've done it for years without a problem.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
D

Douglas J. Steele

You could be right, Roger, I believe that the file handles apply to all
applications running, not just to the Access application. If you're
multi-tasking, you have no way of knowing which handles are being used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top