Exemple #1
0
        public static void SortPhotoByLocation(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoSort_SortPhotoByGeoLocation");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();
            var sortPhoto = new SortedPhoto();

            foreach (var photo in massPhoto)
            {
                var geolocation = InfoImage.GetLocationPhoto(photo);
                if (geolocation != null)
                {
                    var location = InfoImage.GetLocality(geolocation);
                    if (Directory.Exists(pathNew + $"\\{location}") == false)
                    {
                        sortPhoto.CreateDirectoryOfName(pathNew, location);
                    }
                    photo.CopyTo(pathNew + $"\\{location}\\{photo.Name}", true);
                }
                else
                {
                    if (Directory.Exists(pathNew + $"\\NoneGeolocation") == false)
                    {
                        sortPhoto.CreateDirectoryOfName(pathNew, "NoneGeolocation");
                    }
                    photo.CopyTo(pathNew + $"\\NoneGeolocation\\{photo.Name}", true);
                }
            }
        }
Exemple #2
0
        public static void SortPhotoByYears(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoSort_SortPhotoByYear");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();
            var sortPhoto = new SortedPhoto();

            foreach (var photo in massPhoto)
            {
                var datePhoto = InfoImage.ImageDate(photo).ToString("Y");
                if (Directory.Exists(pathNew + $"\\{datePhoto}") == false)
                {
                    sortPhoto.CreateDirectoryOfName(pathNew, datePhoto);
                }
                photo.CopyTo(pathNew + $"\\{datePhoto}\\{photo.Name}", true);
            }
        }