473,666 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textFile Manipulation

I have a textfile with multiple line. How do i get (for example) the 1st line
or the 3rd line then change the line to something i want in C#? How do i
delete a line in C#... or backspace in a textfile? for example

1st line
2nd line
3rd line
4th Line

I want to read the 2nd line and change the string 2nd line to string 4th
line. Anyone knows how to do this? Or i want to Delete 2nd line and move up
3rd and 4th line so there will be no space.. i need the code to do this..
does anybody have the idea? thank you so much!
Mar 30 '06 #1
2 1671
you can make a string array and load the all the lines to this array and
then change the array as you want and then rewrite it to the file.
"Rain" <Ra**@discussio ns.microsoft.co m> wrote in message
news:B9******** *************** ***********@mic rosoft.com...
I have a textfile with multiple line. How do i get (for example) the 1st
line
or the 3rd line then change the line to something i want in C#? How do i
delete a line in C#... or backspace in a textfile? for example

1st line
2nd line
3rd line
4th Line

I want to read the 2nd line and change the string 2nd line to string 4th
line. Anyone knows how to do this? Or i want to Delete 2nd line and move
up
3rd and 4th line so there will be no space.. i need the code to do this..
does anybody have the idea? thank you so much!

Mar 30 '06 #2
Hi

You will have to read all the lines in either an Array or an ArrayList (
preferred ) and change them at will, after you are done you can just write
the lines back to disk
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Rain" <Ra**@discussio ns.microsoft.co m> wrote in message
news:B9******** *************** ***********@mic rosoft.com...
I have a textfile with multiple line. How do i get (for example) the 1st
line
or the 3rd line then change the line to something i want in C#? How do i
delete a line in C#... or backspace in a textfile? for example

1st line
2nd line
3rd line
4th Line

I want to read the 2nd line and change the string 2nd line to string 4th
line. Anyone knows how to do this? Or i want to Delete 2nd line and move
up
3rd and 4th line so there will be no space.. i need the code to do this..
does anybody have the idea? thank you so much!

Mar 30 '06 #3

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

Similar topics

7
5001
by: Hans A | last post by:
I have a textfile "textfile.txt" containing a list of words. There is one word on each line. I want to pick two random lines from this textfile, and I have tried to do something like: //Loading the file into an array: $textarray = file("textfile.txt); //Using array_rand to pick two random words $rand_numbers = array_rand($textarray, 2);
1
2533
by: Larry Rekow | last post by:
I have a report that's created each day as a flat textfile. Because I came from the Access world, I created a macro that imports it with a schema that gives meaningful names to the various columns, and then uses a query to massage some of the data for me (deletes the first blank row and does a couple of calculations) Then I use DTS to import the Access query as a table. the textfile has a column called "File_num", and among several...
1
3127
by: Michael Schindler | last post by:
Ich habe es nun erreicht, ein textfile einzulesen das nun zeile für zeile im datagrid angezeigt wird. Nun wäre es toll wenn ich das textfile zum beispiel nach jedem blank in eine spalte zerstückeln könnte und meine frage hier wie geht sowas? Ich habe nun das ganze mit folgendem code im datagrid, nur zu welchem zeitpunkt zerstückle ich das und meine eigentliche frage wie kann ich das dann in die jeweiligen spalten stellen?
4
1535
by: Kevin Johnson | last post by:
Hi Using C# and a textfile I need to do two things: 1. Read the contents of the textfile and return the number of words contained in it. 2. Output a list of unqiue words (i.e. not duplicated) to a new textfile. These words should appear on a new line. eg. hello
2
2596
by: chris | last post by:
Hi there, I am reading in a textfile which looks like this (there is no new line after the last number) 03 98661881 0407 566453 The code to load the textfile looks like this:
7
2529
by: Peter Proost | last post by:
Hi, I'm creating an import module to read data from old textfiles, run some calculations on them and save them to sql server. I've figured out how to do a select on textfile using a schema.ini file (my textfile is delimeted by a | ) But I've got on problem remaining, below you can so two example rows out of the textfile: 560000||TS|alu dak|0000000067|P400|20|7101|401|0|0|0|0|||||N|J 560039||KM|"De Gaer":
1
1806
by: kachokaratz | last post by:
well i have a problem in my project..since the contents of my textfile is too long, i was wondering how to output the textfile in such a way that you can divide the contents to be able to output everything in an organized manner.. my problem is that since my textfile is too long, when i run the program, the output omits the first parts of the textfile and i end up only seeing the latter parts.. how can i solve this in c language?
14
3317
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands of rows with about 50 coloums every row.. Everythings goes well until I found one textfile with some strange character...seems to be Japanese character(because it's a Japanese company who owns this textfile)
1
2809
by: asedt | last post by:
With my Excel macro and two text files I want to create a new textfile containing the first textfile then text from the sheet and then the second textfile. My problem is that i don't know how to append the second textfile. Sub mysub() Dim TempString As String 'Open the first file Dim fileA As Integer
0
8454
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
8362
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
8785
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
8560
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
8644
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
7389
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
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2776
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

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.