public static bool TryGetUserProfileImagePath(int userId, ProfileImageSize profileImageSize, out string userProfileImagePath, string fileExtensionsToSearch = "jpeg,png") { var extensions = fileExtensionsToSearch.Split(','); foreach (var ext in extensions) { var path = $"{AppDirectoryManager.GetUserProfileImageDirectory(userId)}\\{profileImageSize.ToString()}.{ext}"; if (File.Exists(path)) { userProfileImagePath = path; return(true); } } userProfileImagePath = null; return(false); }
public static void RemoveUserProfileImagesExceptOriginal(int userId) { var profileImages = Directory.GetFiles(AppDirectoryManager.GetUserProfileImageDirectory(userId)); profileImages.ForEach(image => File.Delete(image)); }