Download file has HTML in it.

F

forest demon

i have a file on the server, then use the following code to dialog the
file to the local client.
in stepping through the code the file length (fLen) is correct, but
when i look at the file after
download, it has all the HTML markup appended to the file. i've played
with this a number of
different ways but to no avail.

any help is much appreciated.


string root = @"C:\temp\";
string filepath = @"C:\temp\tempo_file.csv";
FileInfo fyl = new FileInfo(filepath);
string fLen = fyl .Length.ToString();
if ((filepath != null))
{
if (File.Exists(filepath) & filepath.StartsWith(root))
{
Response.Clear();
Response.ContentType = "text/plain";
Response.AddHeader("Content-Length", fLen);
Response.AddHeader("Content-Disposition", "attachment;
filename=\"" + fyl.Name + "\"");
Response.Flush();
Response.TransmitFile(filepath);
}
}

thanks...

-fd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top