示例#1
0
        public static Bitmap LoadPicture(string url)
        {
            CookieAwareWebClient client = new CookieAwareWebClient(BotBase.CcDictonaryNet);
            Stream s   = client.OpenRead(url);
            Bitmap bmp = new Bitmap(s);

            return(bmp);
        }
示例#2
0
        public void SaveImageFromUri(string workingRootPath, string fileNamePath, ImageFormat format, String uri, String cookieName, String cookieValue)
        {
            CookieAwareWebClient client = new CookieAwareWebClient();

            if (cookieName != null && cookieValue != null)
            {
                client.CookieContainer.Add(new Uri(uri), new Cookie(cookieName, cookieValue));
            }
            Stream stream         = client.OpenRead(uri);
            Bitmap bitmap; bitmap = new Bitmap(stream);

            if (bitmap != null)
            {
                DirectoryInfo directoryInfo = CreateFolder(workingRootPath, "validation");
                bitmap.Save(fileNamePath, format);
            }

            stream.Flush();
            stream.Close();
            client.Dispose();
        }