Пример #1
0
        //Delete Video from set of videos for level
        //Return true if no videos left, false if other videos exist
        public static bool  DeleteVideo(VideoData video, bool alsoRemoveConfig = true)
        {
            var levelPath = GetLevelPath(video.level);
            var dir       = new DirectoryInfo(levelPath);

            foreach (var file in dir.EnumerateFiles(video.videoPath.Substring(0, video.videoPath.Length - 4) + "*"))
            {
                Plugin.logger.Debug($"Deleting {file.Name}");
                try
                {
                    file.Delete();
                }
                catch (System.IO.IOException e)
                {
                    //Re-Delete
                    Plugin.logger.Error(e);
                }
                catch (Exception e)
                {
                    Plugin.logger.Error(e);
                }
            }

            video.DeleteVideoFiles();

            //File.Delete(GetVideoPath(video));
            if (alsoRemoveConfig)
            {
                if (RemoveVideo(video))
                {
                    File.Delete(Path.Combine(levelPath, "video.json"));
                    levelsVideos.Remove(video.level);
                    return(true);
                }
                else
                {
                    VideoDatas thisLevelsVideos = GetVideos(video.level);
                    SaveVideosToDisk(thisLevelsVideos);
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }