| |

VerySource

 Forgot password?
 Register
Search
View: 795|Reply: 8

How do I read each [Section] in the ini

[Copy link]

3

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-3 20:00:01
| Show all posts |Read mode
The contents of the ini file are as follows:
[Sky castle]
Coordinates = 1240 500 500
[Underground blood pool]
Coordinates = 300 500 500
[Ghost land]
Coordinates = 400 500 650


If you want to read the contents of [] and the data after "coordinate =", how should you write a statement to read the file!
Thank you ~
Reply

Use magic Report

3

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-1-3 20:03:01
| Show all posts
The read [] content is added to "sign_lsb.Items.Add ()"
Reply

Use magic Report

0

Threads

56

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-3 22:51:01
| Show all posts
Read the string line by line and then process the string.
Reply

Use magic Report

3

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-1-4 01:09:01
| Show all posts
Is there a direct function to call the contents of []
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-4 04:57:01
| Show all posts
Match match;
    Regex regSection = new Regex (@ "^\[(? <Key>. +)\] $");

 match = regSection.Match (fileDataLine);
                if (match.Success)
                {
                    match.Result ("$ {key}");
                }
Reply

Use magic Report

3

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-1-4 08:12:01
| Show all posts
Can you write a little bit more? Where does the path go from
Reply

Use magic Report

3

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-1-4 08:36:01
| Show all posts
The only data you want in ini is "[]"? If the path is "E:\\1.ini"
The content is:
[Sky castle]
Coordinates = 1240 500 500
[Underground blood pool]
Coordinates = 300 500 500
[Ghost land]
Coordinates = 400 500 650
I want to show all the data in "[]" to "sign_lsb.Items.Add ()"
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 United States

Post time: 2020-1-9 20:09:01
| Show all posts
Mark
Reply

Use magic Report

0

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-19 18:18:01
| Show all posts
Read / Write XML files, Config files, INI files, or the Registry
By Alvaro Mendez
http://www.codeproject.com/csharp/readwritexmlini.asp
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list