示例#1
0
文件: Program.cs 项目: ppetrov/Cchbc
        private static void Zip()
        {
            var archive = new ZipArchive();

            foreach (var file in Directory.GetFiles(@"C:\Logs", @"*.*", SearchOption.AllDirectories))
            {
                Console.WriteLine("Compressing file " + file);
                using (var fs = File.OpenRead(file))
                {
                    archive.AddFileAsync(file, fs, CancellationToken.None).Wait();
                }
            }

            Console.WriteLine(@"Save the file");
            using (var fs = File.OpenWrite(@"C:\temp\archive.dat"))
            {
                archive.SaveAsync(fs, CancellationToken.None).Wait();
            }


            using (var fs = File.OpenRead(@"C:\temp\archive.dat"))
            {
                archive.LoadAsync(fs, CancellationToken.None).Wait();
            }


            Console.WriteLine("Completed");
        }
示例#2
0
 private async Task CreateLogEntry(ZipArchive dump, string sourcePath, string logsFolder, string?overrideLogName = null)
 {
     if (File.Exists(sourcePath))
     {
         string logName = overrideLogName ?? Path.GetFileName(sourcePath);
         _logger.Information($"Saving log {logName} . . .");
         await dump.AddFileAsync(sourcePath, Path.Combine(logsFolder, logName));
     }
 }
示例#3
0
        private async Task SaveModConfigs(ZipArchive dump)
        {
            _logger.Information($"Saving configs in {GameConfigsPath} . . .");
            foreach (string configPath in await _debugBridge.ListDirectoryFiles(GameConfigsPath))
            {
                try
                {
                    using TempFile tempPath = _specialFolders.GetTempFile();
                    _logger.Information($"Downloading {configPath} to {tempPath} . . .");
                    await _debugBridge.DownloadFile(configPath, tempPath.Path);

                    await dump.AddFileAsync(tempPath.Path, Path.Combine(GameConfigsDirectory, Path.GetFileName(configPath)));
                } catch (Exception ex) {
                    _logger.Warning($"Failed to download config {configPath}: {ex}");
                }
            }
        }
示例#4
0
 /// <summary>
 /// Saves the config file to a dump.
 /// </summary>
 /// <param name="dump">The dump to save to</param>
 private async Task SaveConfig(ZipArchive dump)
 {
     _configManager.SaveConfig();
     await dump.AddFileAsync(_configManager.ConfigPath, "configs/QuestPatcher_config.json");
 }