public ImageFile(string fileName, string rootPath, string setCode = null, string artist = null, bool isArt = false) { var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); if (fileNameWithoutExtension == null) { throw new ArgumentException(@"fileName is null", nameof(fileName)); } string directoryName = Path.GetDirectoryName(fileName); if (directoryName == null) { throw new ArgumentException(@"directoryName is null", nameof(fileName)); } FullPath = fileName; string[] parts = fileNameWithoutExtension.Split(Array.From('.'), StringSplitOptions.None); var lastNamePart = Enumerable.Range(0, parts.Length) .Last(i => i == 0 || // Richard Garfield, Ph.D..xlhq.jpg // S.N.O.T..xlhq.jpg // Our Market Research....xlhq.jpg parts[i].Length <= 1 || // Sarpadian Empires, Vol. VII.xlhq.jpg // Но Thoughtseize.[Size 16x20].jpg !(parts[i].StartsWith("[") && parts[i].EndsWith("]")) && parts[i].Contains(' ')); Type = string.Join(".", parts.Skip(1 + lastNamePart)); var imageName = string.Join(".", parts.Take(1 + lastNamePart)) .Replace(" - ", string.Empty); ImageName = string.Intern(ImageNamePatcher.PatchFileName(imageName)); var nameParts = ImageName.SplitTalingNumber(); Name = string.Intern(nameParts.Item1); VariantNumber = nameParts.Item2; rootPath = rootPath.ToAppRootedPath(); if (!rootPath.EndsWith("\\")) { rootPath = rootPath + "\\"; } if (!directoryName.EndsWith("\\")) { directoryName = directoryName + "\\"; } if (setCode != null) { SetCode = string.Intern(setCode); SetCodeIsFromAttribute = true; } else { var setCodeMatch = _setCodeRegex.Match(directoryName.Substring(rootPath.Length)); if (setCodeMatch.Success) { SetCode = string.Intern(setCodeMatch.Value.ToUpperInvariant()); } else { SetCode = string.Empty; } } Quality = getQuality(); if (artist != null) { Artist = string.Intern(artist); } IsArt = isArt; IsToken = directoryName.IndexOf("Tokens", Str.Comparison) >= 0; }