这是为什么。隐藏不起作用?

时间:2018-04-07 19:00:10

标签: c# winforms

我试图为我的程序创建一个autoupdater,基本上只是打开我的程序,同时保持autoupdater打开。

我尝试更改版本和代码工作(关闭并打开dl链接)。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using MaterialSkin;
using MaterialSkin.Controls;

namespace Sinips
{
    public partial class Form1 : MaterialForm
    {
        public Form1()
        {
            InitializeComponent();
            var materialSkinManager = MaterialSkinManager.Instance;
            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;
            materialSkinManager.ColorScheme = new ColorScheme(Primary.Grey900, Primary.Grey800, Primary.Grey800, Accent.LightBlue200, TextShade.WHITE);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            WebClient checkVer = new WebClient();
            string Version = checkVer.DownloadString("https://pastebin.com/raw/vSLsy7CF");
            if(Version != "1.0.0")
            {
                WebClient dl = new WebClient();
                string link = dl.DownloadString("https://pastebin.com/raw/ALTc67JZ");
                System.Diagnostics.Process.Start(link);
                this.Close();
            }
            else
            { 
                Form2 main = new Form2();
                this.Hide();
                main.Show();
            }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

尝试将visible设置为false

 this.Visible=false;
 Form2 main = new Form2();
 main.Show();