localhost/xxx/xxx.aspx で実行されている IIS に Web サイトをデプロイしました。私のWPF側では、localhostサーバーからwebclientを使用してテキストファイルをダウンロードし、それをwpfアプリフォルダーに保存します。これが私のやり方です:
protected void DownloadData(string strFileUrlToDownload)
{
WebClient client = new WebClient();
byte[] myDataBuffer = client.DownloadData(strFileUrlToDownload);
MemoryStream storeStream = new MemoryStream();
storeStream.SetLength(myDataBuffer.Length);
storeStream.Write(myDataBuffer, 0 , (int)storeStream.Length);
storeStream.Flush();
string currentpath = System.IO.Directory.GetCurrentDirectory() + @"\Folder";
using (FileStream file = new FileStream(currentpath, FileMode.Create, System.IO.FileAccess.ReadWrite))
{
byte[] bytes = new byte[storeStream.Length];
storeStream.Read(bytes, 0, (int)storeStream.Length);
file.Write(myDataBuffer, 0, (int)storeStream.Length);
storeStream.Close();
}
//The below Getstring method to get data in raw format and manipulate it as per requirement
string download = Encoding.ASCII.GetString(myDataBuffer);
}
これは、btyes を書き込んで保存することによって行われます。しかし、複数の画像ファイルをダウンロードして WPF アプリ フォルダーに保存するにはどうすればよいですか? この localhost/websitename/folder/designs/ のような URL があり、この URL の下に多くの画像があります。それらすべてをダウンロードするにはどうすればよいですか? WPFアプリフォルダーに保存しますか?
基本的には、コンテンツが実際に画像であるフォルダーのコンテンツをダウンロードしたいと考えています。