/// <summary>
        /// Imports a <see cref="MotionPackage"/> from a directory.
        /// </summary>
        /// <param name="directoryPath">The directory to import from.</param>
        public static MotionPackage FromDirectory(string directoryPath)
        {
            var fullDirectoryPath = Path.GetFullPath(directoryPath);
            var propertiesPath    = Path.Combine(fullDirectoryPath, PropertiesFileName);
            var fileOrderPath     = Path.Combine(fullDirectoryPath, FileOrderFileName);

            if (!File.Exists(propertiesPath))
            {
                throw new FileNotFoundException($"{propertiesPath} does not exist.");
            }

            if (!File.Exists(fileOrderPath))
            {
                throw new FileNotFoundException($"{fileOrderPath} does not exist.");
            }

            var properties = MotionPackageAnimationProperties.FromJson(propertiesPath);
            var fileOrder  = File.ReadAllLines(fileOrderPath);

            // Should be order independent if mutating MTP sizes, but this would require hardcoded index modification for most used MTPs...
            // TODO? Add this if requested
            // var files      = Directory.GetFiles(fullDirectoryPath, $"*.{MotionExtension}");
            // TODO: FileNotFound check since we no longer confirm if file exists
            var animations = fileOrder.Select(x =>
            {
                var file     = Path.Combine(fullDirectoryPath, x);
                var bytes    = File.ReadAllBytes(file);
                var fileName = Path.GetFileNameWithoutExtension(file);

                return(properties.Files.ContainsKey(fileName) ? new ManagedAnimationEntry(fileName, bytes, properties.Files[fileName])
                                                              : new ManagedAnimationEntry(fileName, bytes, null));
            });

            return(new MotionPackage(animations.ToArray()));
        }
        /// <summary>
        /// Extracts the current <see cref="MotionPackage"/> and all associated properties to a directory.
        /// </summary>
        /// <param name="directoryPath">The directory to extract to.</param>
        public void ToDirectory(string directoryPath)
        {
            var animationProperties = new MotionPackageAnimationProperties(this);
            var fullDirectoryPath   = Path.GetFullPath(directoryPath);
            var propertiesPath      = Path.Combine(fullDirectoryPath, PropertiesFileName);
            var fileOrderPath       = Path.Combine(fullDirectoryPath, FileOrderFileName);

            File.WriteAllBytes(propertiesPath, animationProperties.ToJson());

            var orderList = new List <string>();

            foreach (var entry in Entries)
            {
                var filePath = Path.Combine(fullDirectoryPath, $"{entry.FileName}.{MotionExtension}");
                File.WriteAllBytes(filePath, entry.FileData);
                orderList.Add($"{entry.FileName}.{MotionExtension}");
            }
            File.AppendAllLines(fileOrderPath, orderList);
        }