Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Skale
Skale

ASKER

Hi ste5an,

You're great!. It's working good.
Avatar of 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
if (!build && line.StartsWith("version.build"))
{
    build = true;
    this.Build = int.Parse(line.Substring(line.IndexOf('=') + 1));
}

Open in new window