Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to download images

private string fileDL (string sUrl, string sDLDir)

    System.Net.WebClient DLClient = null;

    string stitle = Path.GetFileName (sUrl);
    string fileName = string.Format ("{0} {1}", sDLDir, stitle);
    SafeCreateDirectory (sDLDir);
    long sz = 0;
    string ext = "";
    Uri u = new Uri (sUrl);

    CRetryHelper.RetryIfError (() =>
        if (DLClient == null)
            DLClient = new System.Net.WebClient ();
        DLClient.DownloadFileAsync (u, fileName);

            FileStream fs = new FileStream (fileName, FileMode.Open, FileAccess.Read);
            sz = fs.Length;
            ext = System.IO.Path.GetExtension (fileName);
            fs.Close ();
            fs.Dispose ();
            sz = 0;

    ex =>
    ex => (((sz> 3000) && (ext == "png")) || ((sz> 20000) && (ext == "jpg"))), 3);

    return fileName;

↑ I'm downloading an image. Is there a way to reduce the file size of the image and download it?


  • jezhjezh Member, Xamarin Team Xamurai

    Is there a way to reduce the file size of the image and download it?

    A more common approach is to reduce the size of the original image rather than processing it during the download process, as this can affect download speed and efficiency.

Sign In or Register to comment.