예제 #1
0
        private FileFinderInfo GenerateFileFinderInfo(string filePath, string dirPath)
        {
            var ffInfo = new FileFinderInfo();

            ffInfo.DirPath  = dirPath;
            ffInfo.FullPath = filePath;
            using (var md5 = MD5.Create())
            {
                using (var str = File.OpenRead(filePath))
                {
                    var hash = md5.ComputeHash(str);
                    ffInfo.Checksum = ToHex(hash, false);
                }
            }
            var info = new FileInfo(filePath);

            ffInfo.Suffix       = info.Extension.ToLower();
            ffInfo.Name         = info.Name;
            ffInfo.SizeInBytes  = info.Length;
            ffInfo.CreationTime = info.CreationTime;

            if (ffInfo.Suffix == ".jpg")
            {
                try
                {
                    using (ExifReader reader = new ExifReader(filePath))
                    {
                        if (reader.GetTagValue <DateTime>(ExifTags.DateTimeDigitized, out DateTime datePictureTaken))
                        {
                            ffInfo.exif_datetaken = datePictureTaken;
                        }
                    }
                }
                catch (Exception)
                {
                    WriteLine("No exif data");
                }
            }
            return(ffInfo);
        }
예제 #2
0
 private void SaveInfoToDB(FileFinderInfo ffInfo)
 {
     dbconn.Execute(insertQuery, ffInfo);
 }