private void MoveVideoFiles(Video video) { string basePath = this.ConfigAccessor.GetConfigValue(videoRootDirKey); string incomingVideosPath = this.GetIncomingVideosPath(); string targetPath = Path.Combine(basePath, video.VideoCategory.Name); if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } string urlEncodedVideoFileName = UrlStripper.RemoveIllegalCharactersFromUrl(video.VideoFileName); string urlEncodedThumbnailFileName = UrlStripper.RemoveIllegalCharactersFromUrl(video.ThumbnailFileName); string urlEncodedPosterFileName = UrlStripper.RemoveIllegalCharactersFromUrl(video.PosterFileName); File.Move(Path.Combine(incomingVideosPath, video.VideoFileName), Path.Combine(targetPath, urlEncodedVideoFileName)); File.Move(Path.Combine(incomingVideosPath, video.ThumbnailFileName), Path.Combine(targetPath, urlEncodedThumbnailFileName)); File.Move(Path.Combine(incomingVideosPath, video.PosterFileName), Path.Combine(targetPath, urlEncodedPosterFileName)); video.VideoFileName = urlEncodedVideoFileName; video.ThumbnailFileName = urlEncodedThumbnailFileName; video.PosterFileName = urlEncodedPosterFileName; }
/// <summary>Encodes an url to an friendly Url.</summary> /// <see cref="http://stackoverflow.com/questions/25259/how-do-you-include-a-webpage-title-as-part-of-a-webpage-url/25486#25486"/> /// <param name="helper">The helper.</param> /// <param name="urlToEncode">The URL to encode.</param> /// <returns>The friendly Url.</returns> public static string ToFriendlyUrl(this UrlHelper helper, string urlToEncode) { return(UrlStripper.RemoveIllegalCharactersFromUrl(urlToEncode)); }