G
G
Gennady2015-08-20 09:41:17
Programming
Gennady, 2015-08-20 09:41:17

How to read files and get parameters in c#?

Hello!
There was a need to read a file with a list of databases (1C).
I need to get a list of databases from this file and a way\data to connect to them.
File like:
[1C:Document flow]
Connect=Srvr="server address";Ref="database name";
ID=4aed1c5a-a2ef-460f-8334-f5cdfa108cf0
OrderInList=16384
Folder=/
OrderInTree=17408
External=0
ClientConnectionSpeed=Normal
App=Auto
WA=0
Version=8.3
There are a lot of databases in this file (everything is formatted the same way + section names are also added) .
Please tell me the logic of the program that would pull out the names of the databases and connection parameters from the file.
The only option in my mind is to take the first lines + add the number of lines with unnecessary info and take the next ones, etc. But when changing partitions, you will need to re-calculate.
Well, there is an idea to use regular expressions and take all lines that begin with certain characters.
Tell me experienced people how to do it right in this case?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Martyanov, 2015-08-20
@genana40

This is a regular INI file, google what your language has to work with it.

K
Kirill Bobykin, 2015-08-20
@Qelphybox

I don't know anything about c#, but I'm sure regular expressions will handle this situation the best. This is exactly what will help you.

A
AtomKrieg, 2015-08-20
@AtomKrieg

You probably don’t even need to google, but like this:
https://github.com/search?l=C%23&q=ini&type=Reposi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question