예제 #1
0
        public bool TryReadMonitoringReleaseDate(out DateTime releaseDate)
        {
            releaseDate = DateTime.MinValue;
            var tempFile = Path.Combine(Path.GetTempPath(), $@"ServiceControl.Monitoring\{Constants.MonitoringExe}");

            try
            {
                using (var zip = ZipFile.Read(FilePath))
                {
                    var entry = zip.Entries.FirstOrDefault(p => p.FileName == $"ServiceControl.Monitoring/{Constants.MonitoringExe}");
                    if (entry == null)
                    {
                        return(false);
                    }

                    entry.Extract(Path.GetTempPath(), ExtractExistingFileAction.OverwriteSilently);
                    return(ReleaseDateReader.TryReadReleaseDateAttribute(tempFile, out releaseDate));
                }
            }
            catch
            {
                return(false);
            }
            finally
            {
                File.Delete(tempFile);
            }
        }
        public static bool TryReadReleaseDate(this PlatformZipInfo zipInfo, out DateTime releaseDate)
        {
            releaseDate = DateTime.MinValue;
            try
            {
                using (var zip = ZipFile.Read(zipInfo.FilePath))
                {
                    var entry = zip.Entries.FirstOrDefault(p => Path.GetFileName(p.FileName) == zipInfo.MainEntrypoint);
                    if (entry == null)
                    {
                        return(false);
                    }

                    var tempPath = Path.GetTempPath();
                    var tempFile = Path.Combine(tempPath, entry.FileName);
                    try
                    {
                        entry.Extract(tempPath, ExtractExistingFileAction.OverwriteSilently);
                        return(ReleaseDateReader.TryReadReleaseDateAttribute(tempFile, out releaseDate));
                    }
                    finally
                    {
                        File.Delete(tempFile);
                    }
                }
            }
            catch
            {
                return(false);
            }
        }