Download file using Response.TransmitFile is giving checksum mismatch

I am using Response.TransmitFile to enable download feature on my web site and the file size is 2GB. It was working fine till last month. But now customers are complaining that the file downloaded from the size is corrupt. We tried on multiple browser and found the checksum is not matching. When we manually copy the files, checksum is matching. Files at source are not corrupt and is verified. Below is the code snippet used. Could this checksum mismatch is induced by web server? The file downloaded ends up being slightly more in file size compared to file in source. Please help.

            UserInfo objUserInfo = (UserInfo)Session["USER_INFO"];
            string strDocname = ((LinkButton)sender).CommandArgument.ToString();
            strDocname = strDocname.Replace("\r\n", "");
            strSource = ConfigurationManager.AppSettings["DOWNLOAD_PATH"].ToString() + Path.GetFileName(strDocname);
            new Log().logInfo("GotoSystem_onCommand", strSource);
            FileInfo file = new FileInfo(strDocname);
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + strDocname + "");
            Response.TransmitFile(strSource);
            UpdateDownloadLog(objUserInfo.GetUserAcctId(), strDocname, Session["BRAND"].ToString());
            HttpContext.Current.ApplicationInstance.CompleteRequest();
Ashwini RaoSystem ArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brijesh GandhiProgrammerCommented:
Add Below Header in Code and try it
Response.AddHeader("Content-Length", file.Length.ToString());

Open in new window

And also make sure this I think it should be
   FileInfo file = new FileInfo(strSource );

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ashwini RaoSystem ArchitectAuthor Commented:
Brijesh,

Thanks so much. It worked, but not sure why we need to add this line. Could you explain this for my understanding?
Brijesh GandhiProgrammerCommented:
In past I also got this kind of error . So I am aware of this .. For more detail you can refer below link
Content Length
Need of Content Length
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Applications

From novice to tech pro — start learning today.