V
V
vladimirchelyabinskiy2016-09-05 11:58:37
C++ / C#
vladimirchelyabinskiy, 2016-09-05 11:58:37

C# How to find a block of text in a file and replace multiple duplicate lines?

Good day, dear users, faced such a problem.
I have a file operator.rl
With this content
ID=cc7d5671-b10f-4da5-a4ee-f16dc89bfe16
InfComType=EnterpriseRate
INN=
Key=EnterpriseRate_1BN
LastName=
MiddleName=
Name= SERVER1
POPPort=110
POPServer= server1.pop.ru
Post=
SMTPPort= 25
SMTPServer=server1.smtp.ru
Type=Operator
ID=2eab72f5-324f-429d-9746-1662b62e25f9
InfComType=EnterprisePfr
INN=
Key=EnterprisePfr_
LastName=
MiddleName=
Name= SERVER2
POPPort=110
POPServer= 92.255.247.94
Post=
SMTPPort=25
SMTPServer= 92.255.247.94
Type=Operator
How can I take these lines from a file and change servers and ports to different ones.
POPPort=110
POPServer= server1.pop.ru
SMTPPort=25
SMTPServer=server1.smtp.ru
POPPort=110
POPServer= 92.255.247.94
SMTPPort=25
SMTPServer= 92.255.247.94
I have a mechanism to check server availability, I just need to fetch these lines and replace the servers if they are not available

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-09-05
@k1lex

Form regular expressions
And then use a simple replacement of what you found with the one you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question