2011年2月18日金曜日

ホームページの画像を保存

ファイル名、保存形式を指定して保存
WebClient^ client = gcnew WebClient;
Stream^ stream = client->OpenRead(imgUrl);
Bitmap^ image1 = gcnew Bitmap( stream );
stream->Close();
String^ savePath =  "D:\\img\\" + "imgFileName" + "gif";
image1->Save(savePath, System::Drawing::Imaging::ImageFormat::Gif);

直接保存
String^ remoteUri = imgUrl;
String^ fileName = "D:\\img\\Button3.gif", ^myStringWebResource = nullptr;
WebClient^ myWebClient = gcnew WebClient;
//myStringWebResource = String::Concat( remoteUri, fileName );
myWebClient->DownloadFile( remoteUri, fileName );

0 件のコメント:

コメントを投稿