Hello I have created webfrom in asp.net on which
user can upload kml file (Google earth file)..I have saved uploaded filein folder and file path in database.
Now on download button click I have to give same file for download
I got file path from database but I am unable to write code for download funcionality
Below is my download button click code :
- protected void btndownloadkml_Click(object sender, EventArgs e) {
- con.Close();
- SqlCommand cmdkml = new SqlCommand("select * from FileMaster where ClientId='" + ddlclient.SelectedValue.ToString() + "' and FileType='KML' order by Srno DESC", con);
- con.Open();
- SqlDataReader sdrkml = cmdkml.ExecuteReader();
- if (sdrkml.HasRows) {
- sdrkml.Read();
- Response.ContentType = "application/vnd.google-earth.kml+xml";
- string s1 = sdrkml.GetValue(3).ToString();
- string s2 = sdrkml.GetValue(4).ToString();
- Response.AppendHeader("Content-Disposition", "attachment; filename=" + s2);
- Response.TransmitFile(Server.MapPath(s2));
- Response.End();
- }
- }
please suggest changes