ASP.Net Web Forms: How to download a file? How to save string to a file?
private void SaveFile(string featureKey)
{Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=FeatureKey.txt");
if (Response.IsClientConnected)
{
var buffer = Encoding.ASCII.GetBytes(featureKey);
var length = featureKey.Length;
Response.OutputStream.Write(buffer, 0, length);
}
Response.Flush();
Response.End();
}
Comments
Post a Comment