public async Task <FileSystemScanService> OpenFromFile(string filename, FileSystemScanService scanService) { var jsonScanData = await Task.Run(() => File.ReadAllText(filename)); var ss = JsonConvert.DeserializeObject <FileSystemScanService>(jsonScanData); scanService.CopyProperties(ss); return(scanService); }
public void CopyProperties(FileSystemScanService fromScanService) { BaseFolder = fromScanService.BaseFolder; ComputerName = fromScanService.ComputerName; OSVersionName = fromScanService.OSVersionName; ScanDate = fromScanService.ScanDate; ScanOptions.BaseFolderPath = fromScanService.ScanOptions.BaseFolderPath; ScanOptions.IncludeSubFolders = fromScanService.ScanOptions.IncludeSubFolders; ScanOptions.SearchPattern = fromScanService.ScanOptions.SearchPattern; ScanOptions.ShowMinimumFolderLevelInLog = fromScanService.ScanOptions.ShowMinimumFolderLevelInLog; UserName = fromScanService.UserName; DetailType = fromScanService.DetailType; Clear(); ScanResult.AllFolders.AddRange(fromScanService.ScanResult.AllFolders); ScanResult.AllFiles.AddRange(fromScanService.ScanResult.AllFiles); ScanResult.ScanExceptions.AddRange(fromScanService.ScanResult.ScanExceptions); LogLines.AddRange(fromScanService.LogLines); }
public async Task SaveToFile(string filename, FileSystemScanService scanService) { var jsonScanData = JsonConvert.SerializeObject(scanService, SaveReadableFormat ? Formatting.Indented : Formatting.None); await Task.Run(() => File.WriteAllText(filename, jsonScanData)); }