Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Direct file access w/older I/O stmts

Status
Not open for further replies.

mcnorth

Technical User
Aug 27, 2002
17
0
0
US
My project is a dll for downloading and updating stock data in the metastock format. It's all binary for which I'm using;

Open "FileName" For Binary As #1 Len = Len(MyRec)

'do stuff here

Close #1

kind of statements and functions.

The problem I am head butting at the moment is when I open an existing file, delete some data (really just re-write it) I can not figure out how to shorten the file length.

Let's say, for simplicity, I just want to delete the last 28 bytes and save the changes. How do I close the file so that it is 28 bytes shorter than it was when I began? So far the only solution I can see is to delete and re-write the whole file except for the last 28 bytes which doesn't seem very efficient.
 
That is the solution.
Perhaps a more efficient method would be possible if the file was short (say less than 32K)
In this case, you could set up a string of filelen-28,
read that chunk in, and write it out.
One read, one write.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top