How to open the FTP site and download files asp.net

I think that in a ASPX page to write a a tag, the link address to FTP address, tags are as follows:
<a href="FTP address"></a>

Then click the a tab, you can open the FTP site, see the inside of the file, but only word files can be downloaded, other format file click directly opens, as shown in Fig.:

And the red line on the text displayed as shown in style rather than the normal font format, please help solve the master, thank you!

Started by Vernon at November 09, 2016 - 2:22 PM

I for the novice, think the problem is relatively simple, please master a lot of pointing, thank you!

Posted by Vernon at November 20, 2016 - 2:57 PM

Method:   
HttpResponse resp = System.Web.HttpContext.Current.Response;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
resp.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlPathEncode(FileName));
resp.Write(sb.ToString());

 

Methods two:  

Console.WriteLine(sb.ToString());
FileStream aFile = new FileStream("D:\\temp\\lintest.dat", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(aFile);
sw.Write(sb.ToString());
sw.Close();

 

Methods three:  

Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/richtext";
Response.AddHeader("content-disposition", "attachment; filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8) + ";size=0");
Response.Write(sb.ToString());
Response.Flush();
Response.End();

Posted by Nancy at November 25, 2016 - 3:12 PM

Only three methods to understand, but I this is to click the a tab directly into the FTP site is not a new page, the code I what to write.?

Posted by Vernon at November 28, 2016 - 3:45 PM

How come no one.?

Posted by Vernon at December 08, 2016 - 3:59 PM

aligadoxksktkgsdksaglkasgllkagllakgklasglkasg

Posted by Rita at December 14, 2016 - 4:53 PM

What language? The birds? You see

Posted by Vernon at December 28, 2016 - 5:12 PM

Upstairs is by the form of stream to write files to the specified directory, and then make download box form available for download. .

Posted by Brian at January 12, 2017 - 6:12 PM