mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-11 14:14:57 -05:00
Move System.Drawing usage out of Core to WinForms, as System.Drawing is not in .NET Core/Standard. Simple methods to return resource name strings have been added instead.
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Net;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
public class NetUtil
|
|
{
|
|
public static string getStringFromURL(string webURL)
|
|
{
|
|
try
|
|
{
|
|
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL);
|
|
HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
|
|
var reader = new StreamReader(httpWebReponse.GetResponseStream());
|
|
return reader.ReadToEnd();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e.Message);
|
|
return null;
|
|
}
|
|
}
|
|
public static Image getImageFromURL(string webURL)
|
|
{
|
|
try
|
|
{
|
|
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL);
|
|
HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
|
|
Stream stream = httpWebReponse.GetResponseStream();
|
|
return stream != null ? Image.FromStream(stream) : null;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e.Message);
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|