2011年2月18日金曜日

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

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

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

0 件のコメント:

コメントを投稿