GetTimeStamp() приватный статический Метод

private static GetTimeStamp ( ) : string
Результат string
Пример #1
0
        public static void Archive(string originDir)
        {
            if (ArchiveDuration == -1 || DateTime.UtcNow > LastArchive + TimeSpan.FromHours(ArchiveDuration))
            {
                var destination = !String.IsNullOrEmpty(Destination) && Destination.Length > 0 ? Destination : DefaultDestination;

                if (!Directory.Exists(destination))
                {
                    Directory.CreateDirectory(destination);
                }

                var year  = DateTime.UtcNow.Year.ToString();
                var month = new DateTimeFormatInfo().GetMonthName(DateTime.UtcNow.Month);

                if (!Directory.Exists(Path.Combine(destination, year)))
                {
                    Directory.CreateDirectory(Path.Combine(destination, year));
                }

                if (!Directory.Exists(Path.Combine(destination, year, month)))
                {
                    Directory.CreateDirectory(Path.Combine(destination, year, month));
                }

                ZipFile.CreateFromDirectory(originDir, Path.Combine(destination, year, month, AutoSave.GetTimeStamp() + ".zip"), CompressionLevel.Optimal, true);

                Utility.WriteConsoleColor(ConsoleColor.Yellow, "New save archive created. Next Archive: {0}", DateTime.UtcNow + TimeSpan.FromHours(ArchiveDuration));

                LastArchive = DateTime.UtcNow;
            }
        }
Пример #2
0
        public static string Archive(string originDir)
        {
            var destination = !String.IsNullOrEmpty(Destination) && Destination.Length > 0 ? Destination : DefaultDestination;

            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            var year  = DateTime.UtcNow.Year.ToString();
            var month = new DateTimeFormatInfo().GetMonthName(DateTime.UtcNow.Month);

            if (!Directory.Exists(Path.Combine(destination, year)))
            {
                Directory.CreateDirectory(Path.Combine(destination, year));
            }

            if (!Directory.Exists(Path.Combine(destination, year, month)))
            {
                Directory.CreateDirectory(Path.Combine(destination, year, month));
            }

            ZipFile.CreateFromDirectory(originDir, Path.Combine(destination, year, month, AutoSave.GetTimeStamp() + ".zip"), CompressionLevel.Optimal, true);

            return(destination);
        }