asp.net 如何实现打开ftp站点并下载文件的功能
我是这样想的在一个aspx页面中写一个a标签,其链接地址为ftp地址,标签如下:
方法一:
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());
方法二:
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();
方法三:
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();