I am currently working on a project where by I need to check the size of a file that is being downloaded from the website. I know that by default the file that is allocated is 4MB and I can change that in the web config file, the question is if the file size is greater than 4MB the system should display an error. my page is like this

and the code behind look like this

private void btnExtract_Click(object sender, System.EventArgs e)

 DataView dataView =  testReportData.WorktestItem.DefaultView;

            MemoryStream ms = new MemoryStream();
            BinaryFormatter f = new BinaryFormatter();
            f.Serialize(ms, testReportData);
            if (ms.Length < 4096)
                this.ErrorLbl = Page.FindControl("ErrorLbl");
                ErrorLbl.Visible = true;
                ErrorLbl.Text = "error";


any idea how can I solve this issue

Related posts

Recent Viewed