Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 3rd, 2004, 08:05 PM
Registered User
 
Join Date: Mar 2004
Location: O, ON, Canada.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert a new line at beginning of text file? how?

Hello,

does anyone know of a way to insert a new line at the beginning of a text file? It can't overwrite the existing first line. Seems like a simple thing, I know, but it seems there is no easy way to do this.

There's nothing that I can see in the stream writer or file system objects to do this, and I've been searching for many hours and it seems like this is not a common thing (which is probably why there's no info readily available on it).

Any ideas?

thanks

Reply With Quote
  #2 (permalink)  
Old March 3rd, 2004, 09:12 PM
Authorized User
 
Join Date: Oct 2003
Location: , , New Zealand.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure what you are trying to do but you could try using "vbcrlf" (carriage return, line feed).

eg. if you are reading in a text file to a textbox you could add a blank line at the top by:

Dim objReader As StreamReader = New StreamReader("C:\test101.txt")
TextBox1.Text = vbCrLf & objReader.ReadToEnd()
objReader.Close()
objReader = Nothing



Reply With Quote
  #3 (permalink)  
Old March 3rd, 2004, 09:20 PM
Authorized User
 
Join Date: Oct 2003
Location: , , New Zealand.
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...if you to want to ingnore the first line of the text file and read this to the testbox then try:

Dim objReader As StreamReader = New StreamReader("C:\test101.txt")
objReader.ReadLine()
TextBox1.Text = objReader.ReadToEnd()
objReader.Close()
objReader = Nothing

Reply With Quote
  #4 (permalink)  
Old October 13th, 2008, 06:40 AM
Registered User
 
Join Date: Oct 2008
Location: singapore, , Singapore.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can anyone help to solve the below problem which i am facing

i have two files "a.txt" and "b.txt"

i need to copy first line of a.txt to first line of b.txt.
seems like simple but,it is a little difficult.

please reply with a smart VBA code which helps to solve this.

--Vish

"Always finish stronger than you start"
Reply With Quote
  #5 (permalink)  
Old October 13th, 2008, 10:28 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

open the two files. create a new file.. copy the first line of "a.txt", then copy all the lines of "b.txt".
that is your algorithm... I don't think anyone will code it for you.. but if you have a specific question you can always ask....

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #6 (permalink)  
Old October 15th, 2008, 08:36 PM
Registered User
 
Join Date: Oct 2008
Location: singapore, , Singapore.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

i know that no one will code for me.
i can see that in the forum(lot of coding stuff).

if iam not wrong my question was very specific.
jus to copy 1st line of a file to first line of b file.

you have answered in words not in code.

i have posted a question for which i need a code, not a theoretical answer.
i am little poor in coding (in learning stage). if you want to suggest with code and rest i will try.
but the way you answer is a little harsh. sorry to say that mr.

anyway thank you.
please help if i post any questions, please dont give such an answer.

"Always finish stronger than you start"
Reply With Quote
  #7 (permalink)  
Old October 15th, 2008, 09:44 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Since you are learning, this is a good way to learn.. why not give it a try?.. google has a lot of help about opening files, reading then, and closing then...

The code is not long and my answer was not harsh.

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #8 (permalink)  
Old October 15th, 2008, 09:51 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Quote:
quote:please reply with a smart VBA code which helps to solve this.
Ummm...if you want a VBA answer, then why are you posting in the VB.NET forum???

If you are using VBA, post in the appropriate forum for the VBA-based product you are working with (e.g, Word, Excel, Access, Powerpoint).
Reply With Quote
  #9 (permalink)  
Old October 15th, 2008, 09:55 PM
Registered User
 
Join Date: Oct 2008
Location: singapore, , Singapore.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much for the reply,

from next time if i have any .net queries, i will definitely post to u guys.

please help.

Thanks a lot

Regards
Vish

"Always finish stronger than you start"
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
store a single line of text from a file....how???? danielnixon General .NET 2 May 1st, 2008 12:09 PM
Most efficient way to insert text into a file StumblingInTheDark Visual Basic 2005 Basics 1 February 22nd, 2007 01:09 PM
How to read a line from a text file ? nobitavn94 C# 3 November 25th, 2006 11:04 PM
how can I insert a new line at top of text file? Satorikin VB.NET 1 March 4th, 2004 03:41 AM



All times are GMT -4. The time now is 12:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.