.NET 4.x Использование отдельных решений - C#

Узнай цену своей работы

Формулировка задачи:

Еще раз здравствуйте. столкнулся с такой проблемой. Я подключил к своему проекту готовое решение и не могу понять как его выполнить Суть в том что при нажатии кнопки в Form1.cs должен выполняться autoupdate.cs в autoupdate.cs скрипт авто-обновления
using System;
using System.IO;
using System.Net;
 
namespace AutoUpdate
{
    class autoupdate
    {
 
        public static string updateServer = "сыль на сайт";
        public static int currentVersion = 0;
 
        static void Main(string[] args)
        {
            string[] updateInfo;
 
            updateInfo = GetUpdateInfo(updateServer);
 
            if (currentVersion < Convert.ToInt32(updateInfo[0]))
            {
                Console.WriteLine("Необходимо обовиться");
 
                for(int i = 1; i < updateInfo.Length; i++)
                {
                    File.WriteAllBytes(updateInfo[i].Replace('\r', ' '), DownloadFile(updateServer + updateInfo[i].Replace('\r', ' ')));
                }
 
                Console.WriteLine("Все");
 
            }
            else
            {
                Console.WriteLine("Куда пошел???");
            }

            Console.ReadKey();
 
        }
 
        public static byte[] DownloadFile(string url)
        {
            var wc = new WebClient();
            return wc.DownloadData(url);
        }
 
        public static string[] GetUpdateInfo(string url)
        {
            var wc = new WebClient();
            return wc.DownloadString(url + "файл.txt").Split(Convert.ToChar('\n'));
        }
 
    }
}

Решение задачи: «.NET 4.x Использование отдельных решений»

textual
Листинг программы
using System;
using System.IO;
using System.Net;
 
namespace AutoUpdate
{
    class autoupdate
    {
        public static string updateServer = "сыль на сайт";
        public static int currentVersion = 0;
 
        public autoupdate()
        {
            string[] updateInfo;
 
            updateInfo = GetUpdateInfo(updateServer);
 
            if (currentVersion < Convert.ToInt32(updateInfo[0]))
            {
                Console.WriteLine("Необходимо обовиться");
 
                for (int i = 1; i < updateInfo.Length; i++)
                {
                    File.WriteAllBytes(updateInfo[i].Replace('\r', ' '), DownloadFile(updateServer + updateInfo[i].Replace('\r', ' ')));
                }
 
                Console.WriteLine("Все");
 
            }
            else
            {
                Console.WriteLine("Куда пошел???");
            }
 
 
            Console.ReadKey();
 
        }
 
        public static byte[] DownloadFile(string url)
        {
            var wc = new WebClient();
            return wc.DownloadData(url);
        }
 
        public static string[] GetUpdateInfo(string url)
        {
            var wc = new WebClient();
            return wc.DownloadString(url + "файл.txt").Split(Convert.ToChar('\n'));
        }
 
    }
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

13   голосов , оценка 3.769 из 5
Похожие ответы