Avatar of Skale
Skale
 asked on

How to parse txt file for specific information in C#

I have a output file like below and i'd like to get some information from it.

How is it possible to get information are there any expert can help me to parse it?

I'd like to run one function and get some information like; file version, version number, version description, version build like single output.

3.0, 20180100, " ", 76

!file.version=3.0! Removing this line will make the file unreadable

!**********************************************************************
! Program Version Information
!**********************************************************************
version.number = 20180100
version.desc   = ''
version.build  = 76

!**********************************************************************
!  Some Other Blocks
!**********************************************************************
some_texts_in_here
.
.
.

Open in new window

C#

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Skale

ASKER
Hi ste5an,

You're great!. It's working good.
Skale

ASKER
Hi ste5an, it's working perfect but how it could be to adopt without using substring because some users open it manually and changing number , sometimes they can add additional space etc. so it won't be turn correct result  in this case
ste5an

if (!build && line.StartsWith("version.build"))
{
    build = true;
    this.Build = int.Parse(line.Substring(line.IndexOf('=') + 1));
}

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes