Reputation: 135
I have a file installer.ini
where, between many rows I have one destination=C:\da\
. I want to get the value after =
and put in a textBox1
. I made this thing with a text file test.txt
but when I changed with installer.ini
doesn't works.
Here is my code :
string installerfilename = path + "installer.ini";
var link =( path + "installer.ini").ToString();
textBox1.Text = File.ReadLines(link)
.First(x => x.StartsWith("destination=\""))
.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1];
When I run the program next error appear :
Sequence containts no matching element
Anyone can say me which is the problem ?
Upvotes: 0
Views: 140
Reputation: 10208
Try removing the double quote from your LINQ query.
string installerfilename = path + "installer.ini";
var link =( path + "installer.ini").ToString();
textBox1.Text = File.ReadLines(link)
.First(x => x.StartsWith("destination="))
.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1];
Upvotes: 3