ここに私のコード。
サーバーに物理的に保存せずにそれを行うことはできますか?
ありがとうございました!!
StringBuilder text = new StringBuilder();
string sFileName = "file.txt";
using (System.IO.StreamWriter SW = new System.IO.StreamWriter(Server.MapPath("docs\\" + sFileName), false, Encoding.ASCII))
{
SW.WriteLine("test");
SW.Close();
}
System.IO.FileStream fs = null;
fs = System.IO.File.Open(Server.MapPath("docs\\" + sFileName), System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + sFileName);
Response.ContentType = "text/plain";
Response.BinaryWrite(btFile);
Response.End();