コード例 #1
0
ファイル: Program.cs プロジェクト: JL-Code/service.demo
 static void Main(string[] args)
 {
     try
     {
         var path = ConfigurationManager.AppSettings["dirPath"] ?? "C:\\1.0.1";
         var loop = Convert.ToInt32(ConfigurationManager.AppSettings["loop"] ?? "0");
         Console.WriteLine("path=>" + path);
         Console.WriteLine("loop=>" + loop);
         for (int i = 0; i < loop; i++)
         {
             var temp = path + "\\" + i;
             CompressUtil.DecompressFile($"{path}.zip", temp);
             var stopiis = @"get-website 'Default Web Site' | where-object { if ($_.Name -ne ''){stop-website $_.Name; get-website $_.Name;}};";
             var script  = $"Copy-Item -Path \"{temp + "\\1.0.1"}\" -Destination \"{temp + "\\copy"}\" -Recurse -Force";
             PowerShellUtil.RunScript(new List <string> {
                 "Get-ExecutionPolicy | Where-Object { if ($_ -nq 'Unrestricted') { set-executionpolicy Unrestricted -confirm:$false -force } };", stopiis, script
             });
         }
         Console.WriteLine("执行完毕。");
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         Console.WriteLine(ex.ToString());
     }
     Console.ReadKey();
 }
コード例 #2
0
        public void UnZipFolder()
        {
            var path = "E:\\4.6.0.70708";

            CompressUtil.DecompressFile(@"E:\\4.6.0.70708.zip");
            var flag = Directory.Exists(path);

            Assert.AreEqual(flag, true);
        }
コード例 #3
0
        public void CopyItem_Test()
        {
            var path = "E:\\1.0.1";

            for (int i = 0; i < 2; i++)
            {
                var temp = path + "\\" + i;
                CompressUtil.DecompressFile(@"E:\\1.0.1.zip", temp);
                var script = $"Copy-Item -Path \"{temp + "\\1.0.1"}\" -Destination \"{temp + "\\copy"}\" -Recurse -Force";
                PowerShellUtil.RunScript(script);
            }
        }