public void FileCreate(string sdata, string filename)
{
if (sdata.Length > 0)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
Response.Charset = "UTF-8";
Response.Write(sdata);
Response.Flush();
Response.End();
}
}
{
if (sdata.Length > 0)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
Response.Charset = "UTF-8";
Response.Write(sdata);
Response.Flush();
Response.End();
}
}
{
if (sdata.Length > 0)
{
Response.Clear();
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
Response.Charset = "UTF-8";
Response.Write(sdata);
Response.Flush();
Response.End();
}
}
提示错误
所以还是把你的字符串保存为一个txt,然后点击链接或者其他的办法查看
然后另存吧
所以还是把你的字符串保存为一个txt,然后点击链接或者其他的办法查看
然后另存吧
public void FileCreate(string sdata, string filename)
{
if (sdata.Length > 0)
{
FileStream fs = new FileStream("c:\\" + filename, FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.Write(sdata);
sw.Flush();
sw.Close();
fs.Close(); FileInfo file = new FileInfo("c:\\" + filename);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length", file.Length.ToString());
Response.Charset = "UTF-8";
Response.WriteFile(file.FullName);
Response.End();
}
}
然后下载该文件, -----像是客户端?
依然提示错误,为什么呢?
Details:Error parsing near '....'
txt
.txt