S
Sabin Finateanu
Hi I'm having problem reading a file from my program and I think it's from a
procedure I'm using but I don't see where I'm going wrong. Here is the code:
public bool AllowUsage()
{
OperatingSystem os = Environment.OSVersion;
AppDomain ad = Thread.GetDomain();
ad.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal wp = (WindowsPrincipal)Thread.CurrentPrincipal;
if(os.Platform == System.PlatformID.Win32NT &&
wp.IsInRole(WindowsBuiltInRole.Administrator) == true)
{
return true;
}
else
{
return false;
}
}
Antd then I call it here:
void MainFormLoad(object sender, System.EventArgs e)
{
if(!this.AllowUsage())
{
MessageBox.Show("You are not an administrator on this system. Program usage
denied.", "ConfigBackup", MessageBoxButtons.OK, MessageBoxIcon.Stop);
this.Close();
}
// Read the Konfig.ini file and store the results
using(StreamReader FStream = new StreamReader("Konfig.ini"))
{
string[] confOptions = new String[9];
string Line;
int i = 0;
while((Line = FStream.ReadLine()) != null)
{
confOptions = Line;
i++;
}
this.textBox1.Text = confOptions[0];
this.textBox2.Text = confOptions[1];
this.textBox3.Text = confOptions[2];
this.textBox4.Text = confOptions[3];
this.textBox5.Text = confOptions[4];
this.textBox6.Text = confOptions[5];
this.textBox7.Text = confOptions[6];
this.textBox8.Text = confOptions[7];
this.textBox9.Text = confOptions[8];
}
this.label7.Text = "phpMyAdmin v" + this.textBox1.Text;
this.label8.Text = "Apache HTTP Server v" + this.textBox2.Text;
this.label9.Text = "MySQL Database Server v" + this.textBox3.Text;
this.label10.Text = "PHP v" + this.textBox4.Text;
}
Can anyone help me?
procedure I'm using but I don't see where I'm going wrong. Here is the code:
public bool AllowUsage()
{
OperatingSystem os = Environment.OSVersion;
AppDomain ad = Thread.GetDomain();
ad.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal wp = (WindowsPrincipal)Thread.CurrentPrincipal;
if(os.Platform == System.PlatformID.Win32NT &&
wp.IsInRole(WindowsBuiltInRole.Administrator) == true)
{
return true;
}
else
{
return false;
}
}
Antd then I call it here:
void MainFormLoad(object sender, System.EventArgs e)
{
if(!this.AllowUsage())
{
MessageBox.Show("You are not an administrator on this system. Program usage
denied.", "ConfigBackup", MessageBoxButtons.OK, MessageBoxIcon.Stop);
this.Close();
}
// Read the Konfig.ini file and store the results
using(StreamReader FStream = new StreamReader("Konfig.ini"))
{
string[] confOptions = new String[9];
string Line;
int i = 0;
while((Line = FStream.ReadLine()) != null)
{
confOptions = Line;
i++;
}
this.textBox1.Text = confOptions[0];
this.textBox2.Text = confOptions[1];
this.textBox3.Text = confOptions[2];
this.textBox4.Text = confOptions[3];
this.textBox5.Text = confOptions[4];
this.textBox6.Text = confOptions[5];
this.textBox7.Text = confOptions[6];
this.textBox8.Text = confOptions[7];
this.textBox9.Text = confOptions[8];
}
this.label7.Text = "phpMyAdmin v" + this.textBox1.Text;
this.label8.Text = "Apache HTTP Server v" + this.textBox2.Text;
this.label9.Text = "MySQL Database Server v" + this.textBox3.Text;
this.label10.Text = "PHP v" + this.textBox4.Text;
}
Can anyone help me?