using System.Net;
using DownKyi.Core.Logging;
using Console = DownKyi.Core.Utils.Debugging.Console;
namespace DownKyi.Core.Storage;
internal static class StorageUtils
{
///
/// 下载图片
///
///
///
///
public static bool DownloadImage(string url, string localFile)
{
try
{
WebClient mywebclient = new WebClient();
mywebclient.DownloadFile(url, localFile);
}
catch (Exception e)
{
Console.PrintLine("DownloadImage()发生异常: {0}", e);
LogManager.Error("StorageUtils", e);
return false;
}
return true;
}
///
/// Bitmap转BitmapImage
///
///
///
/*public static BitmapImage BitmapToBitmapImage(Bitmap bitmap)
{
BitmapImage result = new BitmapImage();
using (MemoryStream stream = new MemoryStream())
{
bitmap.Save(stream, ImageFormat.Bmp);
stream.Position = 0;
result.BeginInit();
result.CacheOption = BitmapCacheOption.OnLoad;
result.StreamSource = stream;
result.EndInit();
result.Freeze();
}
return result;
}*/
}