public static void SavePictureFromUrl(Rom rom, string url, string folder, bool saveAsJPG)
        {
            try
            {
                if (string.IsNullOrEmpty(url))
                {
                    return;
                }

                string extension = url.Substring(url.LastIndexOf("."));
                string imagePath = "image" + extension;

                using (WebClient client = new WebClient())
                {
                    client.Encoding = System.Text.Encoding.UTF8;
                    client.DownloadFile(new Uri(url), imagePath);
                }

                RomFunctions.SavePicture(rom, imagePath, folder, saveAsJPG);
                File.Delete(imagePath);
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        public static void SaveRomPictures(Rom rom, string boxPath, string titlePath, string gameplayPath, bool saveAsJpg)
        {
            if (!string.IsNullOrEmpty(boxPath) && File.Exists(boxPath))
            {
                RomFunctions.SavePicture(rom, boxPath, Values.BoxartFolder, saveAsJpg);
            }

            if (!string.IsNullOrEmpty(titlePath) && File.Exists(titlePath))
            {
                RomFunctions.SavePicture(rom, titlePath, Values.TitleFolder, saveAsJpg);
            }

            if (!string.IsNullOrEmpty(gameplayPath) && File.Exists(gameplayPath))
            {
                RomFunctions.SavePicture(rom, gameplayPath, Values.GameplayFolder, saveAsJpg);
            }
        }
        public static void SavePictureFromUrl(Rom rom, string url, string pictureType, bool saveAsJpg)
        {
            if (url == "")
            {
                return;
            }
            string extension = url.Substring(url.LastIndexOf("."));
            string imagePath = "image" + extension;

            if (url.ToLower().Contains("https:"))
            {
                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
            }

            using (WebClient client = new WebClient())
            {
                client.DownloadFile(new Uri(url), imagePath);
            }

            RomFunctions.SavePicture(rom, imagePath, pictureType, saveAsJpg);
            File.Delete(imagePath);
        }