Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DoCreateEntryFromFile()

static ZipArchiveEntry System.IO.Compression.ZipFileExtensions.DoCreateEntryFromFile ( this ZipArchive destination,
string sourceFileName,
string entryName,
CompressionLevel? compressionLevel )
inlinestaticpackage

Definition at line 18 of file ZipFileExtensions.cs.

19 {
20 if (destination == null)
21 {
22 throw new ArgumentNullException("destination");
23 }
24 if (sourceFileName == null)
25 {
26 throw new ArgumentNullException("sourceFileName");
27 }
28 if (entryName == null)
29 {
30 throw new ArgumentNullException("entryName");
31 }
32 using FileStream fileStream = new FileStream(sourceFileName, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, useAsync: false);
33 ZipArchiveEntry zipArchiveEntry = (compressionLevel.HasValue ? destination.CreateEntry(entryName, compressionLevel.Value) : destination.CreateEntry(entryName));
34 DateTime dateTime = File.GetLastWriteTime(sourceFileName);
35 if (dateTime.Year < 1980 || dateTime.Year > 2107)
36 {
37 dateTime = new DateTime(1980, 1, 1, 0, 0, 0);
38 }
39 zipArchiveEntry.LastWriteTime = dateTime;
40 using (Stream destination2 = zipArchiveEntry.Open())
41 {
42 fileStream.CopyTo(destination2);
43 }
44 return zipArchiveEntry;
45 }

References System.DateTime, System.destination, System.IO.File.GetLastWriteTime(), and System.DateTime.Year.