473,683 Members | 2,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*******@12jab ber.com <--jabber IM ]
Jul 19 '05 #1
5 1830
Delete it and re-create it?

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


"Sugapablo" <ru********@sug apablo.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*******@12jab ber.com <--jabber IM ]

Jul 19 '05 #2
oFSO.OpenTextFi le "C:\file.tx t", 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********@sug apablo.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*******@12jab ber.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*******@12jab ber.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********@sug apablo.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*******@12jab ber.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******** ******@TK2MSFTN GP11.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********@sug apablo.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*******@12jab ber.com <--jabber IM ]


Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4276
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a while statement checking for an empty string "" which I understand represents an EOF in Python. The text file has some blank lines with spaces and other with blanks. Thanks a lot.
0
11998
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to a new file. The script I have is giving me blank lines in the new file. #!/usr/local/bin/perl #program to read systemdata file #and write to systemstats file # #
7
4348
by: Chris | last post by:
Hi I can use a text file as a datasource but am unable to get the datatable to see the text file as having multiple columns. Everything gets put into the first column in the datatable. Sample of code and text file included. Please help Regards
8
2127
by: MLH | last post by:
Am trying to import 20,000+ lines of text in a file FTP'd from a UNIX platform to windows via FTP session in a DOS box. About 2000 records have multiple lines in them separated by CRLF's. That's not the idea. Each line was supposed to be a separate record. I don't know why the 2000 records having MULTIPLE lines of text are so stubborn. I've run UNIX2DOS utility against the raw text file - no help. I know that UNIX and MAC
13
4182
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them from the html page (replace the words in the html page with blank space) I'm new to python and could use a little push in the right direction, any ideas on how to implement this? Thanks!
1
4751
by: Osoccer | last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem: I need a Visual Basic Script file, call it "Move and Reformat Text File.VBS," that will run from a Windows Script Host command-prompt-based version as follows: C:\> Cscript.exe "Move and Reformat Text File.VBS" The objective of the VBScript file, "Move...
6
24151
by: ivan.perak | last post by:
Hello, im a beginner in VB.NET... The thing i would like to do is as it follows.... I have a text file (list of names, every name to the next line) which is about 350000 lines long. I would like to split it and create a new file at every lets say 20000 lines... so, the directory output would have to be something like this:
13
7034
by: jhamb | last post by:
Hi, This code is in Perl (just a trial, not tested) to parse a text file and output to another file. It is used to delete lines that are not required and output lines that the user wants, to a new file. The problems are: 1 This script is giving blank lines in the new file. 2 I have to remove a whole delimitter (#if FOR_LAB) from the text file. 3.The tool should be able to parse the file, and remove FOR_LAB’ed code, with out affecting the...
1
6767
by: Alex T | last post by:
Hello, I have a bit of a problem here: I am trying to make the search find the positions of a string in the text file. The .txt file is very large and the string comes up multiple times, so I need a way to delete part of the txt file up to the point I see the first occurence of the word Here is my code: #include <iostream> #include <iomanip> #include <fstream>
0
8568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8504
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8922
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8751
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2195
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.