Advertisement
Guest User

Untitled

a guest
Jul 7th, 2021
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.IO.Compression;
  5.  
  6. namespace VimeTheme
  7. {
  8.     class Program
  9.     {
  10.         static string GetSystemDisk()
  11.         {
  12.             string system = Environment.GetFolderPath(Environment.SpecialFolder.System);
  13.             string path = Path.GetPathRoot(system);
  14.  
  15.             return path;
  16.         }
  17.  
  18.         static void Download(string url, string path)
  19.         {
  20.             try
  21.             {
  22.                 WebClient webClient = new WebClient();
  23.                 webClient.DownloadFile(url, path);
  24.             } catch (System.Net.WebException)
  25.             {
  26.                 Console.WriteLine("> Ошибка при скачивании архива");
  27.                 Environment.Exit(0);
  28.                 Console.ReadKey();
  29.             }
  30.  
  31.         }
  32.  
  33.         static void Main(string[] args)
  34.         {
  35.             string vw_path = $"{GetSystemDisk()}Users\\{Environment.UserName}\\AppData\\Roaming\\.vimeworld";
  36.  
  37.             Console.WriteLine("> Загрузка архива...");
  38.             Download("https://vimetheme.at.ua/win11.zip", $"{vw_path}\\theme.zip");
  39.  
  40.             Console.WriteLine("> Установка темы...");
  41.  
  42.             try
  43.             {
  44.                 Directory.Delete($"{vw_path}\\.data", true);
  45.             } catch(System.IO.DirectoryNotFoundException) {; }
  46.            
  47.             try
  48.             {
  49.                 ZipFile.ExtractToDirectory($"{vw_path}\\theme.zip", vw_path);
  50.             } catch(System.IO.FileNotFoundException)
  51.             {
  52.                 Console.WriteLine("\n> Ошибка при извлечении содержимого архива");
  53.                 Environment.Exit(0);
  54.                 Console.ReadKey();
  55.             }
  56.  
  57.             File.Delete($"{vw_path}\\theme.zip");
  58.             Console.WriteLine("> Тема успешно установлена. Запустите VimeWorld");
  59.             Console.ReadKey();
  60.         }
  61.     }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement