Click here to Skip to main content
11,921,353 members (63,869 online)
Rate this:
Please Sign up or sign in to vote.
See more: ZIP
Does anyone know how to run 7zip and name the archive the current date and time like: 11012010192708.7z?
Posted 14-Aug-12 7:44am
Edited 14-Aug-12 8:43am
Sergey Alexandrovich Kryukov 14-Aug-12 12:45pm
Does it have anything to do with ASP.NET?
iismoove 14-Aug-12 12:46pm
Sergey Alexandrovich Kryukov 14-Aug-12 12:58pm
Then remove this tag. You are the one who is interested in tag relevance the most. I answered to your question, anyway.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You don't need to "run" 7zip. You can use 7zip library for .NET, which is a .NET wrapper around 7-zip library:[^].

See also this CodeProject article:
C# (.NET) Interface for 7-Zip Archive DLLs[^].

As to the file name, you can name your files any way you want. If you need to get current time, you can use System.DateTime.Now or System.DateTime.UtcNow; please see:[^].

To make a string out of time, use System.DateTime.ToString(string format) with appropriate format string. Please see:[^],[^],[^].

Now you have all you need.

But I would not advise you to use the format you suggested. For most purposes, it's much better to use standard "sortable" format, which formats the time the way that ordering of stings by time is always the same as the files "by name" (standard alphanumerical order), which makes it very convenient to look through the files in the file managers (note that you did not ask us about setting file time, such as creation or last modification time). This format specifier is "s", highly recommended: Year-month-day"T"hours-minutes-seconds.

Abdul Quader Mamun 14-Aug-12 13:13pm
greatly Answered!

Please read my newly posted article and plz comments or vote.
Sergey Alexandrovich Kryukov 14-Aug-12 13:24pm
Thank you, Abdul.
I'll need time to look at this article...
Abdul Quader Mamun 14-Aug-12 13:26pm
ok, when you will get free/time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 553
1 Dave Kreskowiak 245
2 phil.o 160
3 KrunalRohit 134
4 Sergey Alexandrovich Kryukov 132
0 OriginalGriff 6,951
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,171
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web02 | 2.8.151120.1 | Last Updated 14 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100