Method to Create text file:
Using System.IO;
Using SystemsText;
Using System.IO;
Using SystemsText;
private void CreatetxtFile()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("test");
sb.AppendLine("= = = = = =");
sb.AppendLine();
sb.Append("test2");
sb.AppendLine();
sb.AppendLine();
using (StreamWriter outfile = new StreamWriter("c:" + @"\AllTxtFiles.txt"))
{
outfile.Write(sb.ToString());
}
}
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("test");
sb.AppendLine("= = = = = =");
sb.AppendLine();
sb.Append("test2");
sb.AppendLine();
sb.AppendLine();
using (StreamWriter outfile = new StreamWriter("c:" + @"\AllTxtFiles.txt"))
{
outfile.Write(sb.ToString());
}
}
Code to Save the file as dialog :
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=AllTxtFiles.txt");
Response.AppendHeader("Content-Disposition", "attachment; filename=AllTxtFiles.txt");
// specify the path of the file that has to be saved in client machine.
Response.TransmitFile("c://AllTxtFiles.txt");
Response.End();
Response.TransmitFile("c://AllTxtFiles.txt");
Response.End();
The above code will show a save file dialog to save the file.
1 comment:
div id="blur" style="width: 100%;background-color: white;moz-opacity: 0.5;khtml-opacity: .5;
opacity: .5; filter: alpha(opacity=50);z-index: 120;height: 900px;position: absolute;top: 0;left: 0;"
Post a Comment