コード例 #1
0
        public async Task <FilePropertiesList> GetFilePropertiesAsync(FilePropertySource t)
        {
            FilePropertiesList result = new FilePropertiesList();

            if ((t & FilePropertySource.All) == FilePropertySource.All ||
                (t & FilePropertySource.Exif) == FilePropertySource.Exif)
            {
                ImageTagExtractor imageTagsExtractor = new ImageTagExtractor(Path);
                await imageTagsExtractor.ProcessTagsAsync();

                Parallel.ForEach(imageTagsExtractor.Fields, field =>
                {
                    result.Add((FileProperty)field);
                });
            }

            return(result);
        }
コード例 #2
0
        public string GetAttribute(FileAttribute a, string format)
        {
            string result = string.Empty;

            imageTagExtractor = new ImageTagExtractor(fileInfo.FullName);

            int tag = (int)Enum.Parse(typeof(IFDTagCode), a.Name);

            var field = imageTagExtractor.GetTiffTag(fileInfo.FullName, tag);

            if (field == null || string.IsNullOrEmpty(field.Text))
            {
                return(result);
            }

            if (a.Type.Equals("System.DateTime"))
            {
                DateTime date = DateTime.MinValue;
                DateTime time = DateTime.MinValue;

                string[] dateParts = field.Text.Split(' ');
                string   replaced  = dateParts[0].Replace(':', '/');
                DateTime.TryParse(replaced, out date);

                if (date.Year.Equals(DateTime.MinValue.Year))
                {
                    return(string.Empty);
                }

                DateTime.TryParse(dateParts[1], out time);

                DateTime recalculated = date.AddHours(time.Hour).AddMinutes(time.Minute).AddSeconds(time.Second);

                result = recalculated.ToString(format);
            }
            else
            {
                result = field.Text;
            }

            return(result);
        }