Link to home
Start Free TrialLog in
Avatar of scspl
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.
Avatar of Sreedhar Vengala
Sreedhar Vengala
Flag of Australia image

should be able to do on these line: (originally from https://www.experts-exchange.com/questions/24301129/Download-facility-for-my-web-application.html )

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.Message);
    }
  }
  public Bitmap GetImage() {
    return bitmap;
  }
  public void SaveImage(string filename, ImageFormat format) {
    if (bitmap != null) {
      bitmap.Save(filename, format);
    }
  }
}
ASKER CERTIFIED SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial