您好,我正在尝试在 C# 中创建一个按钮,如果您按下它。它应该从附加的 txt 文件中生成一个关于 IP 地址是什么的消息框。但是我遇到了无法修复的错误。我想我的返回类型混淆了,我一直觉得这里是代码。
private String getIPAddress()
{
String x;
using (TextReader configfile = File.OpenText("PC104Configs.txt"))
while (configfile.Peek() > -1) // If therre are no more characters in this line
{
x = configfile.ReadLine();
if (x.Length == 0)
{
// This is a blank line
continue;
}
if (x.Substring(0, 1) == ";")
{
// This is a comment line
continue;
}
if (x == trueIP)
{
// This is the real deal
testPort = configfile.ReadLine();
testIP = trueIP;
return MessageBox.Show(trueIP);
}
} // End of 'while' there are more characters loop
UnitToTest.Text = "";
MessageBox.Show("Specified Configuration Not Found!");
return (false);
}
private void btnSendConfig_Click(object sender, EventArgs e)
{
getIPAddress();
}