how to read a particular setting from a file

D

dotnet dev

Hi,

I have a plain text file called myVersions.ver which will have something
like this:

AppVersion: 1.0
DBVersion: 1.0

I will use this file to keep my app version number and database version.
My problem is that after extensive research I cannot figure out how to
read this file. I mean not simple read in which everything in file is
read as a stream. I want to specify that I want the setting
'AppVersion' or 'DBVersion'.

Basically:

1> I want to open this file
2> Query to read 'Appversion'

How can I do this. It's like reading a key in xml file.

Please Please help.


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
C

Cor Ligthert

Hi

Did you already look in the AssemblyInfo.vb class.

That is in my opinion the easiest way to get what you want to archieve,

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

* dotnet dev said:
I have a plain text file called myVersions.ver which will have something
like this:

AppVersion: 1.0
DBVersion: 1.0

I will use this file to keep my app version number and database version.
My problem is that after extensive research I cannot figure out how to
read this file. I mean not simple read in which everything in file is
read as a stream. I want to specify that I want the setting
'AppVersion' or 'DBVersion'.

Basically:

1> I want to open this file
2> Query to read 'Appversion'

How can I do this. It's like reading a key in xml file.

\\\
Imports System.IO
..
..
..
Dim sr As StreamReader = _
New StreamReader("C:\WINDOWS\WIN.INI")
Do While sr.Peek > -1
Dim strLine As String = sr.ReadLine()
Dim astrParts() As String = Strings.Split(strLine, ": ")
If astrParts.Length > 0 Then
If astrParts(0) = "AppVersion" Then
...
End If
End If
Loop
sr.Close()
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top