コード例 #1
0
        private string MakeKey(FileSystemInfo finfo)
        {
            var fname = finfo.Name.ToLowerInvariant();

            // Special case JPGs
            if (m_jpg_date_taken && Exif.IsJpgFile(finfo.FullName))
            {
                using (var fs = new FileStream(finfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    var exif = Exif.Read(fs, false);
                    if (exif != null && exif.HasTag(Exif.Tag.DateTimeOriginal))
                    {
                        var dat = exif[Exif.Tag.DateTimeOriginal];
                        var ts  = dat.AsString;
                        return(ts + "-" + fname);
                    }
                }
            }

            // Include the file size in the key
            if (finfo is FileInfo fi)
            {
                return(fi.Length + "-" + fname);
            }
            else
            {
                return(fname);
            }
        }
コード例 #2
0
ファイル: Model.cs プロジェクト: psryland/rylogic_code
            /// <summary>Create a key for 'fi'</summary>
            public static string MakeKey(FileInfo fi)
            {
                // Generate a key for the file
                var fname = fi.Name.ToLowerInvariant();

                // Special case JPGs
                if (Exif.IsJpgFile(fi.FullName))
                {
                    using (var fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        var exif = Exif.Read(fs, false);
                        if (exif != null && exif.HasTag(Exif.Tag.DateTimeOriginal))
                        {
                            var dat = exif[Exif.Tag.DateTimeOriginal];
                            var ts  = dat.AsString;
                            return(ts + "-" + fname);
                        }
                    }
                }

                // Include the file size in the key
                return(fi.Length + "-" + fname);
            }