readline - opposite?


I'm using

strText = objOpenFile.Readline

to read a line from a text file. Is there a command to delete that line from the file once I've done with it?


Who is Participating?
Dirar Abu KteishCommented:
AFAIK there ar only three ways to open a file using the filesystemobject - Read, Write and Append.  There is no random R/W access.  Even if there were, there is no easy way to just delete a portion of a file without loading it into a temp space and re-writing it.  You might want to consider placing the info in question in a small DB such as Access instead of a flat text file, if possible.  You could then add and delete records at will.
Well, then, there IS that!
Dirar Abu KteishCommented:
in, they wrote :
"The way the File System Object works, there's no easy way to edit text, delete a line, or even insert a line in the middle of a file. To do anything like that you usually need to read the contents of the file, edit the string that you read and write it back out. There's no reason you can't write it back out to the same filename which would basically achieve the desired result.

However, there is a downside. On a busy site (or even if you're just unlucky) there is the chance that someone else could be editing the same file at the same time you are. With the right timing, this could result in the loss of some or all of the data contained in the file".

I would also suggest what danataylor has said before, if it's pussible, if not you can still use the function in the address I sent you above.
abenbowAuthor Commented:

ok, I am putting it all into a database, the first line is the fieldnames and I'm using it to create a new table. I was having a problem inserting the data into the table but solved that with BULK INSERT. Unfortunately BULK INSERT also adds the first row. I was hoping that deleting the first row would be easy and there by save me trying to work out how to delete it from the database when I don't know the field names or the contents of the table
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.