scspl
asked on
Download facility for my web application
I am using Asp.Net,3.5,C#
and i have an application in which different images are there on it.
I want to put downloading facility for that so that user of my portal can download
those images from it.
My future expansion for this portal would be something like , user can download songs from it.
Thank You.
and i have an application in which different images are there on it.
I want to put downloading facility for that so that user of my portal can download
those images from it.
My future expansion for this portal would be something like , user can download songs from it.
Thank You.
sorry was wrong URL , was from : http://www.codeproject.com/KB/tips/cs_imagedownload.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net;
public class DownloadImage {
private string imageUrl;
private Bitmap bitmap;
public DownloadImage(string imageUrl) {
this.imageUrl = imageUrl;
}
public void Download() {
try {
WebClient client = new WebClient();
Stream stream = client.OpenRead(imageUrl);
bitmap = new Bitmap(stream);
stream.Flush();
stream.Close();
}
catch (Exception e) {
Console.WriteLine(e.Messag
}
}
public Bitmap GetImage() {
return bitmap;
}
public void SaveImage(string filename, ImageFormat format) {
if (bitmap != null) {
bitmap.Save(filename, format);
}
}
}