I want to trigger a BUTTON_CLICK event IF the condition("file.length()<0") is true. I tried as follows but I am getting error as "WindowsFormsApplication1.Form1.info is a 'field' but used as a 'type' ". Can you give your inputs please. Thank you.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private int flag;
public Form1()
{
InitializeComponent();
}
FileInfo info = new FileInfo("c:\\test.txt");
if (info.Length > 0) // throws an error "invalid token if in class"
flag= 1; //throws an error "WindowsFormsApplication1.Form1.info
is a 'field' but used as a 'type' "
//similar error for flag as for info
if(flag==1) //similar error for flag as for info
{
private void button1_Click(object sender, EventArgs e)
{
//Code for Redirection to New Form
}
}
}
}