Пример #1
0
        private bool getDownloadImage(string downURL, string filePathName)
        {
            // 이미지 다운로드
            WebClient myWebClient = new WebClient();

            byte[] data;
            string fileExtention;
            string saveFilePath;
            Uri    downURI = null;

            try
            {
                downURI = getUrlForPunyCode(downURL);
                //data = await myWebClient.DownloadDataTaskAsync(downURI);
                data          = myWebClient.DownloadData(downURI);
                fileExtention = getImageFileType(data);
                saveFilePath  = filePathName + fileExtention;
                File.WriteAllBytes(saveFilePath, data);

                if (!(fileExtention == ".unknow.txt"))
                {
                    parentForm.pictureBoxGoogleDownloaderUpdate(saveFilePath);    // 화면 표시
                    return(true);
                }
                else
                {
                    File.Delete(saveFilePath);
                    return(false);
                }
            }
            catch (Exception e)
            {
                log.Debug(downURI.ToString());
                log.Debug(e.ToString());
                return(false);
            }
        }