/// <summary> /// Gets the version directory. /// </summary> /// <param name="directoryName">Name of the directory.</param> /// <returns></returns> public DirectoryInfo GetVersionDirectory(string directoryName) { var directory = new DirectoryInfo(directoryName); if (!directory.Exists) throw new InvalidOperationException(); var subDirectories = (from subDir in directory.GetDirectories() let match = VersionPattern.Match(subDir.Name) where match.Success orderby int.Parse(match.Groups["major"].Value), int.Parse(match.Groups["minor"].Value), int.Parse(match.Groups["build"].Value), int.Parse(match.Groups["revision"].Value) select subDir).ToList(); for (int i = subDirectories.Count - 1; i >= 0; i--) { var subDirectory = subDirectories[i]; var hash = new DirectoryHash(subDirectory.FullName); try { hash.Validate(); return subDirectory; } catch (HashValidationException ex) { log.Info(string.Format("Error, when trying to validate the directory '{0}':", subDirectory.FullName)); log.Info(ex.Message); } } return null; }
public void HashIsValidatedIfNothingWasChanged() { var directoryHash = new DirectoryHash(location); directoryHash.Save(); var directoryHash2 = new DirectoryHash(location); directoryHash2.Validate(); }