public FileHelper(DateTime lastUpdate, string startDirectory, string name) { this._startDirectory = startDirectory; lastUpdateTime = lastUpdate; modifiedFiles = new List <string>(); createdDirectories = new List <string>(); _totalSize = null; filesMap = new FilesMap(); this.name = name; }
public static void Unpack(string path, string packageName, DateTime packageSynchronizationTime) { try { FilesMap map = Serializer.DeSerializeObject <FilesMap>(packageName + "\\settings.xml"); foreach (SynchronizedFile synchronizedFile in map.synchronizedFiles) { string filePackagePath = packageName + "\\" + synchronizedFile.fileName; string destinationPath = path + synchronizedFile.relativeFilePath; if (!File.Exists(destinationPath) || File.GetLastWriteTime(destinationPath) < packageSynchronizationTime) { File.Delete(destinationPath); File.Copy(filePackagePath, destinationPath); File.SetLastWriteTime(destinationPath, synchronizedFile.lastWriteTime); } } foreach (SynchronizedFile synchronizedDirectory in map.synchronizedDirectories) { string filePackagePath = packageName + "\\" + synchronizedDirectory.fileName + ".zip"; string destinationPath = path + synchronizedDirectory.relativeFilePath; if (Directory.Exists(destinationPath) && Directory.GetLastWriteTime(destinationPath) < packageSynchronizationTime) { Directory.Delete(destinationPath, true); } if (!Directory.Exists(destinationPath)) { ZipFile.ExtractToDirectory(filePackagePath, destinationPath); Directory.SetLastWriteTime(destinationPath, synchronizedDirectory.lastWriteTime); SetLastWriteTimeRecursively(destinationPath, synchronizedDirectory.lastWriteTime); } } Directory.Delete(packageName, true); } catch (Exception e) { throw new NotImplementedException(); } }