PDA

View Full Version : help for modify and save line in file text



kangou
10-19-2008, 04:53 PM
Hi all, I have a question for modify line in file text it is possible ??

I have a text file that contains this
mixer truck File
S 002A 0C 7FD0416DE057D916 ; oct 08
S 002A 0D 7F48120C2A48F5E0 ; nov 08
S 002A 0E 4578D399FB03D7E4 ; service
# **************************
S 0030 0C A62726896BA19B1E ; oct 08
S 0030 0D 5B0404D8321FB86C ; nov 08
S 0030 0E 57327DC2A862B1FB ; service
# **************************
S 02E2 0C A62726896BA19B1E ; oct 08
S 02E2 0D 5B0404D8321FB86C ; nov 08
S 02E2 0E 57327DC2A862B1FB ; service
# **************************
S 0065 0C B00F1A3D7C809C83 ; oct 08
S 0065 0D 31BED657C4A8D43A ; nov 08 "modify is here
S 0065 0E D02F36F0C5B42F23 ; service
# **************************
S 006A 0C 94EC9AD1DAE46CE5 ; oct 08
S 006A 0D A6393DE96AF0EFAF ; nov 08
S 006A 0E 7E36C0A6A08A5150 ; service
-----------------------------------------
New File mixer truck contains this
S 0065 0C D90AC2225F25CC2B
S 0065 0D 2CEC00BF93621613

I would compare new file S 0065 0D 2CEC00BF93621613 and file S 0065 0D 31BED657C4A8D43A ; nov 08 if line idem anything, so different modified line and save without changing the other line

thanx advance for reply and code

presidente
10-19-2008, 05:39 PM
Itīs not easy to understand you.
If you want to compare the text in the different lines of your textfile, i think you should use TextFile.ReadToTable () and later you can use the String.Compare () and other String- functions to find and change lines in this file.

kangou
10-20-2008, 11:38 AM
sorry but it is not easy for me in English, compared the lines, if the line is different, modify the line and then save

thanx

pjborg
10-20-2008, 08:09 PM
Maybe you could use TextFile.ReadToString, then use String.Replace to change the text, then use TextFile.WriteFromString to write the changed text back to the text file?

kangou
10-21-2008, 01:48 AM
Thanx for reply, I'm look and test ;)