Error from Visual Studio 2008

Posts
1
Registration date
Friday September 9, 2011
Last seen
June 11, 2018
-
Hello,

this is the code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace TextHole
{

public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}
private int Lecteur;
private string drive;
private string Ligne;

private int SC_MONITORPOWER = 0xF170;

private uint WM_SYSCOMMAND = 0x0112;

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

private void SetMonitorState(int state)
{
Form frm = new Form();

SendMessage(frm.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)state);

}

private void button1_Click(object sender, EventArgs e)
{

DriveInfo[] allDrives = DriveInfo.GetDrives();


int counter = 0;
string line;

// Read the file and display it line by line.
Text = drive;
try
{
System.IO.StreamReader file = new System.IO.StreamReader(drive + "secret.txt");
while ((line = file.ReadLine()) != null)
{
Ligne = line;
counter++;
}
file.Close();
if (Ligne == "889900")
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkApp.DeleteValue("Drive", false);
SetMonitorState(-1);
MessageBox.Show("Welcome!", null);
return;
}
//Text = Ligne;
}
catch { }
Lecteur = allDrives.Count();
timer1.Start();
}


private void Form1_Load(object sender, EventArgs e)
{

string[] args = Environment.GetCommandLineArgs();

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkApp.SetValue("Drive", Application.ExecutablePath.ToString());
SetMonitorState(2);
DriveInfo[] allDrives = DriveInfo.GetDrives();
Lecteur = allDrives.Count();
timer1.Enabled = true;
timer1.Start();

}

private void timer1_Tick(object sender, EventArgs e)
{
SetMonitorState(2);
DriveInfo[] allLecteur = DriveInfo.GetDrives();
int c = allLecteur.Count();
if (c != Lecteur) { timer1.Stop(); button1_Click(sender, e); }
}


}
}



I have this error message:
Error 1 The name 'timer1' does not exist in the current context

I use visual studio 2008.
I have a function named timer1.what is wrong?
See more