469,280 Members | 1,950 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,280 developers. It's quick & easy.

Erasing all lines from a text file?

I know how to read a text file in ASP, I know how to append lines to a
text file.

How do I simply erase all lines from a text file?

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]
Jul 19 '05 #1
5 1685
Delete it and re-create it?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Sugapablo" <ru********@sugapablo.com> wrote in message
news:sl***********************@dell.sugapablo.net. ..
I know how to read a text file in ASP, I know how to append lines to a
text file.

How do I simply erase all lines from a text file?

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]

Jul 19 '05 #2
oFSO.OpenTextFile "C:\file.txt", 2

You just open it in write mode as opposed to append or reading mode and
don't write anything. I believe that'll do it.

Ray at work

"Sugapablo" <ru********@sugapablo.com> wrote in message
news:sl***********************@dell.sugapablo.net. ..
I know how to read a text file in ASP, I know how to append lines to a
text file.

How do I simply erase all lines from a text file?

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]

Jul 19 '05 #3
In article <OW**************@TK2MSFTNGP09.phx.gbl>, Aaron Bertrand - MVP wrote:
Delete it and re-create it?


Well I did figure that one out, I was just wondering if there was
a better approach.

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]
Jul 19 '05 #4
Unless you need to hold on to non-inherited NTFS permissions or the
dateCreated property of the file, deleting it and recreating it is no better
or worse than any other solution really.

Ray at work

"Sugapablo" <ru********@sugapablo.com> wrote in message
news:sl***********************@dell.sugapablo.net. ..
In article <OW**************@TK2MSFTNGP09.phx.gbl>, Aaron Bertrand - MVP

wrote:
Delete it and re-create it?


Well I did figure that one out, I was just wondering if there was
a better approach.

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]

Jul 19 '05 #5
I think if your code does what you say (I haven't tested it), it probably
achieves it in the same way, with one less line of code. (Delete,
re-create.)

Maybe I should add that task (emptying a file) to http://www.aspfaq.com/2039

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
Unless you need to hold on to non-inherited NTFS permissions or the
dateCreated property of the file, deleting it and recreating it is no better or worse than any other solution really.

Ray at work

"Sugapablo" <ru********@sugapablo.com> wrote in message
news:sl***********************@dell.sugapablo.net. ..
In article <OW**************@TK2MSFTNGP09.phx.gbl>, Aaron Bertrand - MVP

wrote:
Delete it and re-create it?


Well I did figure that one out, I was just wondering if there was
a better approach.

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]


Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John M. Lembo | last post: by
7 posts views Thread by Chris | last post: by
6 posts views Thread by ivan.perak | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.