Download file with progress bar

Posted by: bedwired on 17 September 2023, 11:55 pm EST

  • Posted 17 September 2023, 11:55 pm EST

    Hello everyone, this is my first post here.

    I am working on an ASP.Net Web Forms app and i need to download a file with a progress bar showing the download progress.

    At the moment i am lost in the various methods i found online and didn’t manage to make one work, other than the old System.IO.File.WriteAllBytes(), which doesn’t allow me to update a progress bar.

    Any help?

  • Posted 18 September 2023, 7:40 am EST

    Download worked using this but in the Page_Load only

    Still didnt manage to track the download status

    try
            {
                string filePath = MapPath(path);
                FileInfo file = new FileInfo(filePath);
                if (file.Exists)
                {
                    Response.Clear();
                    Response.ClearHeaders();
                    Response.ClearContent();
                    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + file.Name + "\"");
                    Response.AddHeader("Content-Length", file.Length.ToString());
                    //Response.ContentType = "video/mp4";
                    Response.Flush();
                    Response.TransmitFile(file.FullName);
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                //handle error
            }

  • Posted 18 September 2023, 10:16 pm EST

    Hello,

    There is no such method that detects the progress of the downloading file with the code snippet used.

    Please refer to the following Stackoverflow link that might help you:

    https://stackoverflow.com/questions/9459225/asynchronous-file-download-with-progress-bar

    In client_DownloadProgressChanged method, you may update the progressbar.

    Hope it helps!

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels