I have the next code :
private void Install_Click(object sender, EventArgs e)
{
string configfilename = path + "config.ini";
string installerfilename = path + "installer.ini";
string configtext = File.ReadAllText(configfilename);
string installertext = File.ReadAllText(installerfilename);
var link = File.ReadLines(path + "config.ini").ToArray();
var lin = File.ReadLines(path + "installer.ini").ToArray();
foreach (var txt in link)
{
if (txt.Contains("PLP="))
{
var PLPPath = txt.Split('=')[1];
installertext = installertext.Replace("fileInstallationKey=", "fileInstallationKey=" + PLPPath);
}
else if (txt.Contains("Output="))
{
var outputPath = txt.Split('=')[1];
installertext = installertext.Replace("outlog=", "outlog=" + outputPath);
}
else
{
var license = lin.Select(line => Regex.Replace(line, @"license=.*", "license=yes"));
File.WriteAllLines(installerfilename, license);
var lmgr_files = lin.Select(line => Regex.Replace(line, @"lmgr_files=.*", "lmgr_files=false"));
File.WriteAllLines(installerfilename, lmgr_files);
var lmgr_service = lin.Select(line => Regex.Replace(line, @"lmgr_service=.*", "lmgr_service=false"));
File.WriteAllLines(installerfilename, lmgr_service);
}
File.WriteAllText(installerfilename, installertext);
}
But the problem is this code copies the data from config.ini
in installer.ini
, from the PLP row
, Output
row. And in installer.ini
the rows :license
, lmgr_files
, lmgr_service
are not completed with data : yes
, false
, false
.
With other words who is after else doesn't work .
How I can modify the code to make all statements execute?
In installer.ini
I have many things but the most important are :
license=false //I want to have license=yes
lmgr_files= //I want to have lmgr_files=
lmgr_service=
fileInstallationKey=0000000 //the number from config.ini
outlog="jhaoif" //the code from config.ini