Пример #1
0
        private static void RemoveUnwantedVideoFiles(string destDirName, IEnumerable <string> videoFilesToInclude)
        {
            // If videoFilesToInclude is null or empty, ALL video files in the video subdirectory will be deleted.
            // This likely means that they aren't referenced in the Book's .htm file, although someday there could be
            // other reasons to not include them.
            var videoDir = BookStorage.GetVideoFolderPath(destDirName);

            if (!Directory.Exists(videoDir))
            {
                return;
            }

            foreach (var videoFilePath in Directory.EnumerateFiles(videoDir))
            {
                // videoFilesToInclude strings do not include timings, but do include "video/" prefix,
                // so include the prefix in our Contains() test.
                var fileName = BookStorage.GetNormalizedPathForOS(Path.GetFileName(videoFilePath));
                if (videoFilesToInclude == null || !videoFilesToInclude.Contains(BookStorage.GetVideoFolderName + fileName))
                {
                    RobustFile.Delete(videoFilePath);
                }
            }
        }