Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I need to be able to write to a specific line in a text file.

 

I can get the line number where I want the text to go, but actually writing to that line is the problem.

 

If anyone can help me out it would be great.

 

Thanks

 

Steve

  • *Gurus*
Posted

You must read the whole file in, change the line and then write the whole file out again.

 

If this could cause memory problems, you can always write out the new file as you're reading the old one in on the fly. Either way, there's no way of directly replacing a line in a file.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Ok, I thought there was a way to loop throught the file then stop at the specific line, then change it.

 

I am actually trying tp write an ini file, but I have read xml files are better to use know but I have no idea where to start with them.

 

Are there any good places with examples of them to help me get started?

 

Thanks

 

Steve

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...