Пример #1
0
        public IActionResult Index2(SetupVM vm)
        {
            vm.EntryDir = AppDomain.CurrentDomain.BaseDirectory;
            vm.ExtraDir = vm.EntryDir + "\\" + vm.ExtraDir;
            vm.MainNs   = vm.ExtraNS;
            vm.MainDir  = vm.ExtraDir + "\\" + vm.MainNs;

            if (Directory.Exists(vm.ExtraDir) == false)
            {
                Directory.CreateDirectory(vm.ExtraDir);
            }
            if (Directory.Exists(vm.MainDir) == false)
            {
                Directory.CreateDirectory(vm.MainDir);
            }
            vm.WriteDefaultFiles();
            vm.DoSetup();

            var zipdir = vm.EntryDir + "\\ZipFiles";

            if (Directory.Exists(zipdir) == false)
            {
                Directory.CreateDirectory(zipdir);
            }
            var zipfile = zipdir + "\\" + vm.ExtraNS + ".zip";

            System.IO.Compression.ZipFile.CreateFromDirectory(vm.ExtraDir, zipfile);

            byte[] rv = System.IO.File.ReadAllBytes(zipfile);
            System.IO.File.Delete(zipfile);
            return(File(rv, "application/zip", vm.ExtraNS + ".zip"));
        }
Пример #2
0
        public IActionResult Index2(SetupVM vm)
        {
            vm.EntryDir = AppDomain.CurrentDomain.BaseDirectory;
            vm.ExtraDir = vm.EntryDir + Path.DirectorySeparatorChar + vm.ExtraDir;
            vm.MainNs   = vm.ExtraNS;
            vm.MainDir  = vm.ExtraDir + Path.DirectorySeparatorChar + vm.MainNs;
            string propertydir = vm.MainDir + Path.DirectorySeparatorChar + "Properties";

            if (Directory.Exists(vm.ExtraDir) == false)
            {
                Directory.CreateDirectory(vm.ExtraDir);
            }
            if (Directory.Exists(vm.MainDir) == false)
            {
                Directory.CreateDirectory(vm.MainDir);
            }
            if (Directory.Exists(propertydir) == false)
            {
                Directory.CreateDirectory(propertydir);
            }
            vm.WriteDefaultFiles();
            vm.DoSetup();

            var zipdir = vm.EntryDir + Path.DirectorySeparatorChar + "ZipFiles";

            if (Directory.Exists(zipdir) == false)
            {
                Directory.CreateDirectory(zipdir);
            }
            string g       = Guid.NewGuid().ToString();
            var    zipfile = zipdir + Path.DirectorySeparatorChar + g + ".zip";

            System.IO.Compression.ZipFile.CreateFromDirectory(vm.ExtraDir, zipfile);

            byte[] rv = System.IO.File.ReadAllBytes(zipfile);
            System.IO.File.Delete(zipfile);
            System.IO.Directory.Delete(vm.ExtraDir, true);
            return(File(rv, "application/zip", vm.ExtraNS + ".zip"));
        }